Clean Code Developer
November 4th, 2009
No comments
It’s time to replace the Clean Code Developer bracelet again. The next color, and grade respectively, is the yellow bracelet. Now, the principles become more interesting; The yellow bracelet principles are the foundation of clean object-oriented design. Although they are not that easy to fulfill every time, they should be followed as eagerly as possible. The principles and practices are:
- Interface Segregation Principle: Clients should not be forced to depend upon interfaces that they do not use.
- Dependency Inversion Principle: a) High level classes should not depend upon low level modules. Both should depend upon abstractions. b) Abstractions should not depend upon details. Details should depend upon abstractions.
- Liskov Substitution Principle: a) subclasses have to fulfill the invariants of the superclass. Post-conditions of methods in the superclass have to be fulfilled by overriding methods in subclasses.
- Principles of Least Astonishment: Avoid side-effects. Use, for instance, the command and query separation principle of Bertrand Meyer (Object-Oriented Software Construction).
- Information Hiding Principle: Well, that’s not a principle, that’s an order
- Complex Refactorings: See the Refactoring book by Martin Fowler, his Refactoring Web site, or the Refactoring to Patterns book by Joshua Kerievsky.
- Automated Unit Tests
- Mockups: For Java I recommend JMockit or mockito.
- Code Coverage: I recommend Cobertura (free) or Clover (commercial) which both integrate nicely into Hudson.

