Object Calisthenics – 10 Steps to Better Software Design
Object calisthenics is a simple ruleset that, if applied correctly, should have a big effect on your designs. For the time being, follow these rules; we will discuss the principles behind them later on:
- Only one level of indentation per method
- Don't use the
ELSE
keyword - Wrap all primitives and strings (wrap primitive types in classes)
- First-class collections (wrap collections in classes)
- One dot per line
- Don't abbreviate
- Keep all entities small
- No classes with more than two instance variables
- No getters/setters/properties
- All classes must have state
Object calisthenics does not give you anything new; on the contrary, it takes stuff away. Expect these rules/constraints to be challenging/frustrating if you have never used them before. Be strict for now – no exceptions! The time to bend the rules has not yet come.
Important
Pay extra attention to not...