What is a pattern?
Patterns in programming are like recipes in cooking. They are not ready dishes, but instructions for slicing and dicing products, cooking them, serving them and so forth.
As a rule, a pattern description consists of the following:
- a problem that the pattern solves;
- motivation for solving the the problem using the method suggested by the pattern;
- structures of classes comprising the solution;
- an example in one of the programming languages;
- a description of the nuances of pattern implementation in various contexts;
- relations with other patterns.
Who invents patterns?
By definition, patterns are not invented, but rather discovered. They are not some unique concepts, but, on the contrary, template solutions of the same problem.
The concept of patterns was first described by Christopher Alexander in his book “A Pattern Language: Towns, Buildings, Construction”. The book describes a “language” for designing the urban environment. Its units – templates – answer architectural questions: how high should windows be, how many levels should a building have, how large are green areas in a neighborhood supposed to be and so on.
The idea was picked by four authors: Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm, collectively known as the Gang of Four. In 1995, they published a book called “Design Patterns: Elements of Reusable Object-Oriented Software”, where they applied the concept of typical patterns to programming. The book featured 23 patterns solving various problems of object-oriented design.
Since then, dozens of other object patterns have been discovered. The “pattern approach” became popular in other programming areas as well, so various patterns can now be found far outside object-oriented design.