Object Calisthenics outlines 9 basic rules to apply when performing the exercise:
- One level of indentation per method.
- Don't use the ELSE keyword.
- Wrap all primitives and Strings in classes.
- First class collections.
- One dot per line.
- Don't abbreviate.
- Keep all classes less than 50 lines.
- No classes with more than two instance variables.
- No getters or setters.
Also see the "Your code sucks, let's fix-it" presentation by Rafael Dohms.
@iqbalrohail,
Don’t make decisions outside of the class, let the class do its job, follows the Tell don’t ask principle.
I would prefer to see the above list as guidelines not rules. Also see https://levelup.gitconnected.com/learn-these-9-rules-to-start-writing-clean-code-immediately-a7ee40fe1e1b