- The classes must be coded in this order: Public static constants, private static variables, private instance variables...
- Define variables as private. If any need for testing then change it to protected.
- Small, small, small! Classes should be small. It should have one responsibility which means the description of the class shouldn't include the word 'and'. (Single Responsibility Principle(SRP) is an important concept for OO design.)
- There should be a small number of instance variable in the class. If a method accesses more instance variables, it is more cohesive with the class. If the cohesion is high, then methods have more logical integrity with the class.
- Learn Dependency Inversion Principle (DIP).
Robert C Martin - Clean Code: A Handbook of Agile Software Craftsmanship
No comments:
Post a Comment