3 ms·
Completely agree :) In some cases I prefer to wrap it in an aptly named function, but in other cases I prefer the whole algorithm to be in a single function, ma
by augustl 12y ago
Completely agree :) In some cases I prefer to wrap it in an aptly named function, but in other cases I prefer the whole algorithm to be in a single function, making comments a very useful tool for "naming".
- couchand 12y agoin other cases I prefer the whole algorithm to be in a single function A modern compiler can inline most of your function calls if you like. That way you can factor the code appropriately for both concerns.
- josephlord 12y agoPutting the whole algorithm in a single function isn't for the compiler's benefit but for the reader's. Especially in languages with side effects any function call you need to analyse takes time and then you need to come back to the main function and remember your mental state. Please note that in many cases putting an algorithm in a single function is the wrong choice but there is also a cost in splitting it.