Re:Functions Should Be Short And Sweet, But Why?
by JoeAltmaier on Wednesday January 22, 2014 @10:21AM
(#7103013)
Yes, the idea of writing straightforward code is critical. If you can do it in less lines, even at expense of speed or space, you benefit many-fold. Its easier to understand, read, explain to someone else, remember, debug, compile. The slowest processor in the system is the wetware between your ears. Funny we rarely talk of optimizing for speed or space in that engine!
You can have a fairly long function that's readable and maintainable; those last two are the important part, and, to a point, they hinge more on how much work is being done than how much code it takes.
Of course, if you're just plain writing more code than is needed, that's not a problem with the function itself.