The dark side of design patterns

There's an interesting interview with Rod Johnson (author of Expert One-on-One: J2EE Design and Development) on the ServerSide. It's refreshing to hear a J2EE book author be willing to criticize the typical over-engineering, design-patterns-galore approach that goes on in many J2EE projects.

Many Java developers seem to think the GoF book is their personal bible, and will not hesitate to add factories, proxies, facades, etc. to their project whether they're needed or not. As Rod states

Patterns are valuable, but I've seen a lot of developers go pattern-crazy. They look for opportunities to apply patterns, rather than concentrating on actual requirements. I think we need a more mature approach. We should understand patterns and use them where appropriate, rather than shoehorning them in if they don't fit. Patterns should be used as parts of good solutions, rather than driving solutions.

I could not agree more. I've seen too many systems that were over-engineered in the name of extensibility, but that mainly resulted in code-bloat and unmaintainability.

Design patterns are not inherently good and they don't magically make your code more extensible or maintainable. Instead, they come with added complexity and oftentimes a performance-penalty for your system. This is the price you pay for the problems they attempt to solve. When applicable, this price is more than worth it; when not, you're just throwing your money away.

Comments

Agree 100%. Now that I do TDD I enjoy deleting pretty, over-designed stuff I sometimes code, that's not really required by my tests.

Posted by Steve Conover at February 27, 2003 12:14 PM

Hear! Hear! Struggled with understanding plenty of overpatterned systems. But it was one episode in particular theo brought it all home to me.

I wrote a 150 line Python module that read an XML document via SAX and converted it into tree of domain objects. It plugged the text and attribute values from XML straight into the object attributes and linked up the objects into a hierarchy mirroring the XML.

I was mortified when challenged about the lack of patterns. It was suggested that I should use Visitor, Factory, Singleton, Decorator... which would have turned it into 500 lines with no increase in clarity. Urkk.

Posted by Alan Green at February 27, 2003 6:55 PM

If you have some knowledge of spanish language you can read here an article about over-engineering and solutions for the misuse of patterns. Only in spanish, sorry :/

Posted by Martín at February 28, 2003 3:26 AM
This discussion has been closed. If you wish to contact me about this post, you can do so by email.