Do not create unnecessary methods

Methods should be short, from 1 to 7 lines of code, maximum 10 in some cases (with the exception of some algorithms). Because a method does just one thing its name should describe it precisely. But it should not contain implementation details (like data types). The...

Return: get out as soon as possible

I believe the idea of a single exit point for functions comes from the 70’s. A function used to have only one exit point, a single return statement. I still see some developers doing this but it’s not a good idea. As soon as you have found what you were...

Push the query down: Tell, don’t ask

“Feature envy” is a typical code smell in Object Oriented Programming. It can be appreciated when code talking to an object accesses directly to that object’s fields or properties, from the outside, breaking the encapsulation. // feature envy:...

Add the feature where you would like to find it

A new change or feature is about to be implemented. There are several places where it can fit in, and all of them seem to respect the Single Responsibility Principle. My tendency used to be adding the new feature where it was easier to place.  However now I consider...