Design Patterns: Elements of Reusable Object-Oriented Software

Toward the end of 1994 Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm introduced us to their research published as Design Patterns: Elements of Reusable Object-Oriented Software (Gamma). Together these four guys are colloquially known as the "Gang of Four." Their inspiration was Christopher Alexander, who crafted three books in the 1970s exploring how successful patterns of design (elements that appear over and over) were used in architecture and community planning (Alexander). Other authors have thrown their contributions into the ring with new design patterns, and Grady Booch at one point had a web page accepting and cataloging design patterns. That web page mysteriously disappeared after a while, maybe folks were just creating "new patterns" and grabbing their fifteen minutes of fame? So the twenty three patterns in this book are still the ones that software architects focus on, and this book is one of our bibles for designing object-oriented software.

If you have read any of my work, you will know that I am a huge fan of Robert C. Martin's SOLID principles and DRY (don't repeat yourself) by Andy Hunt and Dave Thomas (Martin, Thomas). Every pattern that the Gang of Four identified is a manifestation of these six principles. In fact, almost 70% use abstractions in the same was a the fundamental principle, only the intention of the pattern is different.

Sometimes working backwards from the patterns can lead to traps. We have favorite patterns, we start looking for problems we can solve with them, and we may miss using the patterns that the design really needs. It is crucial to understand the principles and how to design using them. That will naturally lead to almost all of the patterns, and help us recognize when we may be applying the wrong pattern.

My posts attack this from both directions. Sometimes I explore problems and how we can use the principles to lead to patterns that solve them. Other times I look at the patterns from the outside in. I do what the book does not do: take the problem they are solving, identify why one or more principles need to be used, and how that builds the appropriate design pattern. These articles are the solutions that I have posted so far. I put them in alphabetical order, but if you are starting out with design patterns the best place to start is with the adapter pattern:

  1. Adapter: Plug and Play, also see the blog post: Static is Evil
  2. Decorator
  3. Singleton: There can be only one! 

No comments:

Post a Comment