Wednesday

Clean Code (Robert Cecil Martin) - Chapter 10 Classes - My summary

I have tried to make a short summary for chapter 10 of the Clean Code(Robert Cecil Martin) book. I hope the summary will also be useful for you.
  1. The classes must be coded in this order: Public static constants, private static variables, private instance variables...
  2. Define variables as private. If any need for testing then change it to protected.
  3. 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.) 
  4. 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.
  5. Learn  Dependency Inversion Principle (DIP).
References:
Robert C Martin - Clean Code: A Handbook of Agile Software Craftsmanship 

No comments:

Post a Comment