By Lyudmila Rezunik (lrezunik@edu.hse.ru)
Gang of Four (GoF) design patterns are widely used as an instrument for fighting with reocurring software design problems. Being introduced in 1994 [1] they are still in use and there is no denying that they affected the software development industry. Before going to the topic of the essay, there is need to introduce the basic ideas behind the GoF patterns and why there were and still remain popular among developers.
The book published by so called Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) described 23 design patterns which were classified by their type: creational, structural and behavioral. The patterns themselves described reusable design ideas that were discovered rather than invented, being applied in certain context by real developers. It was profitable to use ready-to-go solutions based on experience of others, and considered modern for the day the patterns got the attention they deserved.
However, nowadays the problem arising with overuse of such patterns becomes prominent. The next sections of the essay will cover the issues and why they appeared. There will also be made an introduction to modern patterns and the field of their use.
Over the past 30 years since the design patterns by GoF were published, software development has evolved dramatically. Monolith architecture that was popular 30 years ago was replaced by the microservices, that happened with an influence of domain-driven-design ideas [2]. Still being relevant within the microservices, the GoF patterns cannot suffice the needs to be applied on the level above (e.g. to manage microservice interaction). It is not their fault, because they were not design for it. Besides microservices, new technologies such containerization and cloud computing emerged, which is also influenced the relevance of design patterns. That is why nowadays it is not enough for a developer to know only GoF patterns (and maybe also GRASP), he should be prepared to also apply more modern approaches to design.
In the next section are going to be describe some of the modern patterns classified by the type of their application.
Being developed in a context of object-oriented programming, GoF patterns are not useful for other paradigms (e.g reactive and functional paradigm).
Talking about reactive programming [3], it is based on the idea of asynchronous event processing and data streams, and became popular in such areas as GUI programming, web programming, microservices, etc. There is important to mention that an influence from Gang of Four patterns can be also seen here, because the Observer pattern is used as a core of reactive programming. However, there are also plenty of more modern patterns in use, for example Reactor pattern, which handles service requests that are delivered concurrently by the producer. The C10k problem (handling large number of clients at the same time) is solved in client-server applications by applying this pattern.
As was mentioned in the previous section, microservices also influenced the relevance of GoF patterns. Some of the modern design patterns that appeared as a result are: API Gateway Pattern and Circuit Breaker Pattern. The first pattern is responsible for providing a single entry point for certain groups of microservices, and the other prevents a microservice from repeatedly trying to execute an operation that is likely to fail. The idea is simple: a circuit breaker object is introduced, and it monitors the failures of remote calls to a function. If the number of failures exceeds a certain threshold, all the further calls will return with an error [4]. These are commonly used patterns among backend developers, I also happened to use them when was developing a microservice application and it was a good solution, that helped to handle remote requests.
There are other areas of software development that evolved in 30 years, and where new design patterns were introduced. It is a long list, so I will mention only a couple more.
Besides all the patterns mentoned above, there are a lot more that we have not considered, which are applied in other areas: DevOps, testing, high-load systems, machine learning, etc. That shows that new patterns are introduced and shared between developers, that is caused by the domain, which is evolving.
Software development has seen a lot of growth in the past years, that is not even mentioning past decades. In this period new design patterns appeared, but it could not be said that they made the GoF patterns less important.
Moreover, although other programming styles are also getting popular (e.g. functional programming), they still cannot replace object-oriented programming. That is why I believe that Gang of Four patterns will remain relevant until OOP remains relevant. However, I need to mention that the overuse of this patterns or applying them incorrectly can lead to bad-smelling code. That fact was already studied and mentioned in some articles [6]. The advice here, I think, is to believe in KISS principle and to try distance yourself from premature optimization.
To conclude the essay, I would like to say that GoF patterns are still important to the industry and the ideas behind those patterns can influence some of the new ones. Above, in the previous section, a few modern patterns were described, but there are many more that were not mentioned. This confirms the fact that in the modern times developers need to learn more about design patterns: they should keep up with the new ones and also keep in mind those that were already established for a long time.