Reading Time: 1 minute
I recently stumbled upon Andrew Binstock’s great article about OO’s Small Classes and Short Methods in which he summarized Jeff Bay’s essay “Object Calistehnics”. Andrew is Editor-in-chief at Dr. Dobb’s and lead developer for Platypus, an OSS typsetting software. You can find Andrew on twitter.
If you want to improve your ability to write OO routines have a look at this exercise by Andrew.
A great exercise to improve Object Oriented Style Coding
- Use only one level of indentation per method.
- Don’t use the ‘else’ keyword.
- Wrap all primitives and strings.
- Use only one dot per line.
- Don’t abbreviate names.
- Keep entities small.
- Don’t use any classes with more than two instance variables.
- Use first-class collections.
- Don’t use setters, getters, or properties.
If you want to read a more in-depth article about this exercise I highly recommend you head over to Andrew’s original article.