In a posting on the Agile Modeling mailing list, Alan Shalloway of Net Objectives, proposed some rules on well designed code:
- Runs all the tests
- Follows once and only once rule
(which I believe means “contains no duplicate code”)
- Has high cohesion (clarity)
- Has loose coupling
“If you look at design patterns, you can see that most of them follow these rules. High cohesion and loose coupling can often be achieved by decomposing your problem domain with the distinctions of commonality / variability analysis. That is, find how things are similar and then find out how they are different.
“The other thing I like about this set of rules is that they are easy to teach and understand. Cohesion has to do with clarity. Method cohesion means a method is focused on one purpose. Class cohesion means all of the methods in a class are focused on one larger purpose.”
Tuesday, 6 April 2010
Emergent Design - These few simple rules, applied locally, can help a high quality global design to emerge.