News for hackers. Stuff that matters.
Re:Functions Should Be Short And Sweet, But Why? by mildtrepidation on Wednesday January 22, 2014 @10:12AM (#7102937)
Functions should be exactly as long as they need to be to accomplish their purpose. The purpose is the important part: A function should have a concise and easily-understood purpose (or very small and logically inseparable set of purposes) and, tangentially, a name that describes it well.

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.

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!