What Characterizes a Pattern?
Get an overview of the characteristics of a simple pattern.
The idea of using patterns was originally coined in the architecture field. Later, using patterns was adopted in other fields, including computer science. So, before diving into design patterns, let’s explain the characteristics of a simple pattern.
Characteristics of a pattern
To discuss the characteristics of a pattern, let’s refer to the definition written by Christopher Alexander. According to him: “Each pattern describes a problem which occurs over and over again … and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.”
This definition aptly explains what should be characteristic of a pattern. According to this definition, a pattern should capture three main parts, described below.
Problem (when)
The context or problem of a pattern should always be clear. This means we should already know which problem we would apply a certain pattern to. However, a specific pattern is not a perfect solution that works for any set of problems. Knowing when to apply a specific pattern is fundamental to any pattern. This also means that when faced with a new problem, we should be able to pick and apply the correct pattern for that particular context.
Solution (how)
The solution section describes how we can approach the given problem. It describes the general structure of our solution. In this step, we devise a blueprint for our solution.
Consequences
This section explains the consequences and benefits of applying the solution. It comes after the solution, as shown in the illustration below. Here, we examine other related patterns, discuss trade-offs, and compare the benefits with our applied solution.
Get hands-on with 1400+ tech skills courses.