13 Dec 2007

Definition of Good Code

In practicing SimpleDesign, I've found Kent Beck's disarmingly simple definition of good code to be invaluable. Basically, good code:
- Passes all the tests
- Clearly expresses intention
- Has no duplication
- Has the fewest number classes and methods

That's it. As a driver for Refactoring in Test Driven Development it has helped me to produce some of my most simple and elegant designs and architectures.

While it's important to understand standard design patterns and object oriented principals such as Single Responsibility, Open Closed, Liskov Substitution, etc. Increasingly I feel that they are just techniques to help achieve a better balance across the above 4 points.