Now that I'm writing more code, I'm always looking to improve how I work. While researching something, I came across a book "The ThoughtWorks Anthology". In it, Jeff Bay wrote an essay on (what he calls) "Object Calisthenics". In it, he lists 9 rules for writing code:
- Only one level of indentation per method.
- Don't use the "else" keyword.
- Wrap all primitives and strings.
- First class collections.
- One dot per line.
- Don't abbreviate.
- Keep all entities small.
- No classes with more than two instance variables
- No getters/setters/properties
Here is a link to a PDF presentation of these points (full essay is in the book).
It's interesting to read, as while it does create a LOT more code, it does seem to make it easier to follow. Does anyone use this technique, or have any points of note about the 9 rules? I'm going to try some exercises and see how I do following the 9 rules & see what comes of it.