Published July 27, 2019
by Doug Klugh

Keep Your Functions Small

When it comes to functions, size matters.  And smaller is always better.  A function should do one thing, do it well, and do it only.  If your functions contain more than a handful of lines, consider extracting those into other functions.  Functions containing multiple blocks of functionality should be extracted into classes of their own (remember the Single Responsibility Principle).  If, While, and Try-Catch blocks should rarely contain more than a single function call.  Exception handling is a responsibility unto itself and should be encapsulated within its own function.

If good Naming Conventions are followed, having small functions will make it much easier to understand, navigate, and maintain your code.