How to use Patterns

Erich Gamma said:

Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problem. Because of this I really like to use patterns after the fact, refactoring to patterns. One comment I saw in a news group just after patterns started to become more popular was someone claiming that in a particular program they tried to use all 23 GoF patterns. They said they had failed, because they were only able to use 20. They hoped the client would call them again to come back again so maybe they could squeeze in the other 3.


Trying to use all the patterns is a bad thing, because you will end up with synthetic designs—speculative designs that have flexibility that no one needs. These days software is too complex. We can't afford to speculate what else it should do. We need to really focus on what it needs. That's why I like refactoring to patterns. People should learn that when they have a particular kind of problem or code smell, as people call it these days, they can go to their patterns toolbox to find a solution.

Published 07-31-2007 12:40 AM by jop
Filed under: ,

Comments

# re: How to use Patterns

i agree. refactor to patterns. otherwise you might end up with YAGNI.

Monday, July 30, 2007 5:04 PM by cruizer

# re: How to use Patterns

When I was starting with Design Patterns I was quick to indentify which I'm gonna need and which is not. Refactoring to patterns is a nice idea I learned from cruizer (I'm referring to the idea, not the book). However, you could use Design Patterns in situations that seem very familiar to you(and assuming you've done something ugly to solve this situation before).

Tuesday, July 31, 2007 1:05 AM by lamia