Stay up to date with the latest developments!
Builder Pattern diagram - Choosing a leased car
You all know those moments when your phone is empty and you don’t have your charger with you. The moment you insert your colleague’s charger into your telephone, you’re dealing with an adapter pattern. The adapter converts between in the European 220 volt outlet that provides the electricity and the phone that expects a USB connection with 5 volts.
At home you use your wireless charger. This is a completely different input, but just as with the 220V charger, it converts the power in exactly the correct way. So after an hour you can return the charger to your colleague, with peace of mind.
Remember your last search for a hotel through the famous blue booking platform? Under your favorite hotel a red bar beckons: already booked four times this past hour. A clever design pattern is at work here: the observer pattern. Web site elements (observers) can register itself at the bookings’ site backend (subject). If something changes in the status of a room or a booking these elements get a notification from the subject and can choose to update their information.
The backend continuously knows if and who has booked a room somewhere. Not only for your room, but for all rooms, apartments and villas. As soon as someone else books and it’s the same room you’ve booked, the backend informs the counter in your browser that the fifth booking is confirmed. And then of course you can’t stay behind...
Design patterns yield an interchangeable structure. But what are the benefits? Just a few of the things they do for us:
Everyone has their own way of working. But the goal is that as soon as someone checks in code, someone else can continue. Design patterns ensure reliability through their ‘proven’ design. And that applies not just to the code, but also to the way you create documentation and notes in your project.
If a project is growing rapidly in size, or someone changes jobs, you want productive newbies. Without design patterns, you would first have to explain to someone the whole coherence of the code, or the way of working. Can you imagine the months and frustrations flying by? If you use design patterns you can say: the updates of this dashboard use an ‘observer’ pattern. Now the newbie knows immediately how to use the code, or where to look up how the pattern works.
Python, C#, Vue, React, r: we use more and more languages and frameworks interchangeably. All these systems build and process objects in their own way. An adapter pattern helps you convert information from an object in Python to one in Vue for example, neutrally. Like translating the objects in Python to JSON and converting the JSON in Vue to a Vue object. Speaking of JSON, an adapter could also make it easy to keep legacy XML code compatible. You ‘just’ write an adapter for that.
If people with the same skills work on many different projects, you’ll deliver faster. At Itility, the software developers are distributed across various customers. They keep each other fully updated on what they’re creating. By using design patterns in their projects, they exchange new functions and workflows efficiently if these also prove useful for their own project. That also means you don’t have to reinvent the wheel for structures that already exist in design patterns.
Okay, design patterns provide reliable code, and make newbies and new projects more productive. But does this also work outside the silo of software engineers? Absolutely! For example, our DevOps engineers work closely alongside the data scientists.
An example of our alerts: the software developer makes a ‘class’ available to the data scientist that implements the builder pattern. This way, the data scientist doesn’t have to worry about exactly how an alert is built up. He only has to focus on using the definition of the builder and add all the information he has regarding the alert. In the background the builder will take care of providing necessary extra information about the application name, links to documentation and network details.
Thanks to design patterns there’s a lot to gain. A pattern can even be useful if you don’t do anything with code, but want to deliver projects in a uniform fashion. Curious about more basic principles about design patterns? Then download the slides of our training design patterns.
And would you like to receive more blogs about software development? Subscribe below.