What Patterns Are

A pattern is a recurring design element in the world or in software. An old saying applies: “Twice is a coincidence; three times is a pattern.” A software pattern is a solution to a software design or coding problem that has been useful at least three times — a requirement known as the Rule of Three (see Chapter 5). The recurrence shows that the pattern is a common solution that works over and over again.

Patterns result when multiple people look at multiple bits of designs or code and notice similarities in the way the design or code is structured. Someone then takes the next step of taking the time to write down the pattern in a way that makes it usable for the many others who haven't had a chance to look at those initial designs.

You start to note similarities in how something is implemented and used when you've seen something happen at least three times. The same basic structure is seen in all the instances, but there are variations. The Composite pattern from Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Addison-Wesley Professional), for example, is used repeatedly to combine different kinds of objects, yet the structure is still that of a Composite. This is okay. A pattern can be seen and used in hundreds of places but never be precisely the same in all the places.


You may ...

Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.