Remembering Design Principles
After taking a look at NDepend and running it on a few projects at work, most of the assemblies seem to either be living in the Zone of Pain or the Zone of Uselessness. While I'm not using NDepend as the silver bullet to tell me who's been naughty or nice, I am wondering how many basic design principles have been forgotten (or some cases never learned in the first place).
The common ones that I keep going back to (and evangelise to those that care) are:
- The single responsibility principle (a class should have only one reason to change)
- The common reuse principle (the classes in a component are reused together. If you reuse one of the classes in a component, you reuse them all)
- The interface segregation principle (clients should not be forced to depend upon methods that they don’t use. Interfaces belong to clients, not to type hierarchies)
- The abstract factory pattern (to trim down dependencies between concrete types)
- The separated interface pattern
There are others, but these are usually the most common and most violated as I keep looking at other peoples code (and my own for that matter).