In Chapter 9, “The Bridge Pattern,” I showed how the Bridge pattern can be derived using commonality/variability analysis. Many other patterns can be derived as well, including the Strategy, Iterator, Proxy, State, Visitor, Template Method, and Abstract Factory. What is more important, however, is how many patterns are implemented by using commonality/variability analysis. Looking for commonalities can help us discover that a pattern is present in our problem domain.
For example, in the Bridge pattern, I may start with several special cases:
Knowing the Bridge helps me see these as special cases of two commonalities:
Drawing programs
Shapes to draw
The Strategy pattern is similar in that when I see several different rules, I know to look for a commonality amongst the rules so I can encapsulate them.
But please keep learning patterns. Read the literature. Patterns provide the backdrop for discussions about lessons learned in analysis and design. They give a team of developers a common vocabulary for discussing a problem. They enable you to incorporate best-practice approaches into your code.