27 มีนาคม 2567
Mathematical Functions
As part of my endeavor to acquire a degree, I'm taking a math course, "Intro to Quantitative Analysis". We're covering functions, and it suddenly makes sense why C++ functions are written (and named) the way they are.
type FunctionName(parameter)
Functions in mathematics are shown very similarly. Let's look at an example.
Marcus currently has 200 songs in his music collection. Every month, he adds 15 new songs. Write a formula for the number of songs, N, in his collection as a function of time, t, the number of months. How many songs will he own in a year?
This function is expressed as N(t) = 15t + 200. We can think of N as our return type, t as our parameter, and the rest as the body of our function:
float NumberOfSongs(float time) { return (15 * time) + 200;}
This doesn't make anything that much easier to understand, but given programming's history as a field developed by mathemeticians, calling things like this a "function" suddenly makes sense, and it does explain why there's a delineation between a "function" and a "method".
18 มีนาคม 2567
Influential Relationships
I remember reading some time ago that a study concluded that companies whose names began with "A" were typically more successful. I wonder if that would still be the case if the American grading system used a different letter to denote the highest possible grade. If grades of 100 were marked with "E", for example, would companies whose names began with "E" typically be more successful in that world?
11 มีนาคม 2567
Maintainability vs. Performance
Maintainability and optimization often butt heads; in my opinion, maintainability takes precedence except where it dramatically impacts performace. In those cases, the code focusing on performance should be black-boxed.