I have been recently dealing with a somewhat tangled set of components where over time, developers have added references as needed to get things done quickly, creating circular and upstream references, resulting in low level layers depending on high level layers. While looking for a nice little refresher online on dependency injection (incidentally, this is a great refactoring technique to fix this situation fast), I found this nice concise definition on bad design provided in an article by Robert C. Martin, Thoughtworks
This seems like a great step to facilitate design reviews in a repeatable manner while avoiding digression into personal preference or opinion. I look forward to reviewing designs on the basis of Rigidity, Fragility and Immobility. For the full article, visit http://www.objectmentor.com/resources/articles/dip.pdf
------------------------------------------- ARTICLE EXCERPT -------------------------------------------
Have you ever presented a software design, that you were especially proud of, for review by a peer? Did that peer say, in a whining derisive sneer, something like: “Why’d you do it that way?”. Certainly this has happened to me, and I have seen it happen to many other engineers too. Clearly the disagreeing engineers are not using the same criteria for defining what “bad design” is. The most common criterion that I have seen used is the TNTWIWHDI or “That’s not the way I would have done it” criterion.
But there is one set of criteria that I think all engineers will agree with. A piece of software that fulfills its requirements and yet exhibits any or all of the following three traits has a bad design.
- It is hard to change because every change affects too many other parts of the sys-
tem. (Rigidity)
- When you make a change, unexpected parts of the system break. (Fragility)
- It is hard to reuse in another application because it cannot be disentangled from
the current application. (Immobility)
Moreover, it would be difficult to demonstrate that a piece of software that exhibits none of those traits, i.e. it is flexible, robust, and reusable, and that also fulfills all its requirements, has a bad design. Thus, we can use these three traits as a way to unambiguously decide if a design is “good” or “bad”
------------------------------------------- ARTICLE EXCERPT -------------------------------------------