In writing code, and in the way its structure is conceived, some architectures keep repeating. For these processes, which come round again cyclically and without fail, an idea was born and developed: to create a model able to simplify and automate stages of the code-writing process.
We are talking about the so-called Design Patterns, which we use all the time at dotenv. Let’s look in detail at what they are.
The added value of Design Patterns in writing code
Everything changes and everything evolves extremely fast, but some elements were born never to change, because if they did they would no longer have any reason to exist. Let’s try to explain what we mean with a couple of examples.
Imagine a wheel with its spokes on the outside of the tyre, or a house with its roof at the level of the foundations. Obvious as they may seem, at the design stage it is essential to know these recurring patterns and give them great consideration. The same happens in the world of code writing: knowing them thoroughly matters both for setting up the software architecture correctly and for simplifying and automating it at some of its key points, so as to build custom software.
These recurring patterns are called Design Patterns. They are a set of models reusable by anyone, which can be placed in any code to design any software. Their “power” is to simplify developers’ work: they mean not having to look every time for solutions to problems that have already been solved (and which, without fail, will come up again), but using a sort of universal key able to automate a precise stage of the code. Of course, the programmer will always play a fundamental role in the process, but Design Patterns certainly help them in writing the code.
Here is a universally recognised definition to help you remember how you can use them to your advantage: “a general design solution to a recurring problem”.
The three categories of Design Patterns

In the book “Design Patterns: Elements of Reusable Object-Oriented Software”, the authors Erich Gamma, John Vlissides, Richard Helm and Ralph Johnson identified three different categories of Design Patterns.
- Structural models, or Structural patterns: these are preset mechanisms for the links between the different classes. In essence, they make software design easier since, by using them, it is possible to structure relationships between classes in a simple way. Their role is to aim for the greatest possible abstraction, so as to be able to communicate with other solutions in the most effective and efficient way.
- Behavioural models, or Behavioral patterns: as their name suggests, they serve to model the behaviour of the software; they are used to simplify what would otherwise be complex command and control processes. In practice, they are Design Patterns able to encode common communication models between the different objects, to the benefit of flexibility in the communication between the objects themselves.
- Creational models, or Creational patterns: these are design models that cover all the stages concerning the creation of objects in the code. By using them it is possible to create objects in the way best suited to the specific context, overcoming all the difficulties linked to the complexity of creating objects according to the context.
Now that you know the main categories of Design Patterns, let’s see together what benefits they bring and what drawbacks they are associated with.
Advantages and disadvantages of Design Patterns
As you will have guessed, the advantages of using Design Patterns are countless. First of all, they offer the possibility of finding and using solutions that have already been widely used before, and are therefore valid and tested. As a result, the programmer will save precious time, which also translates into a financial saving.
These recurring patterns also allow simpler and faster communication between the developers working on the project and contribute to a substantial reduction in the maintenance time of software developed using them.
As for the disadvantages, there are essentially two. First, using Design Patterns requires a fair amount of expertise. It is true that they simplify the architecture stage and, therefore, the writing of the code, but to master them you need to know what you are doing.
The second disadvantage is that their use could affect a developer’s creative abilities, because using mechanisms that are already tried and tested could inhibit their inclination to research and develop new solutions.
Now that you know Design Patterns better, it’s time to find out how we use them!
