How small should functions be?
I'm new at writing professional code (the bulk of my experience is with personal projects) so excuse me if this is trivial. When I write code I find myself being a little inconsistent with how much functionality I include in one function. If I know it's code I'm going to reuse later I'll make a separate function, but when it's something like a check I often find myself either writing a one line function or writing the one line check in every function that needs it. How little functionality is too little? Is return foo == null; too small and could be included in a bigger function as an if statement, or is it acceptable to write a separate function for just a null check?
I'm new at writing professional code (the bulk of my experience is with personal projects) so excuse me if this is trivial. When I write code I find myself being a little inconsistent with how much functionality I include in one function. If I know it's code I'm going to reuse later I'll make a separate function, but when it's something like a check I often find myself either writing a one line function or writing the one line check in every function that needs it.
How little functionality is too little? Is return foo == null;
too small and could be included in a bigger function as an if
statement, or is it acceptable to write a separate function for just a null check?