Last week Ryan Brush (author of Bunsen project) from Cerner published on Github the first version of the SQL-on-FHIR draft. This will be a hot topic to discuss in the upcoming FHIR Connectathon #19…
In simpler words, it is a common Structural Pattern that is designed to separate out implementation-specific and implementation-independent abstractions.
If neither of them helped, I’m completely with you as it’s difficult to understand the Bridge pattern by merely reading the definition. Do read on as we take our infamous Samosa example to explain this ;)
Let’s say we need to write code to support multiple types of Samosas. How well can we structure the code? Let’s take a look at a couple of different ways.
The objective is to write code to support the making of two types of Samosas, i.e., AlooSamosa and ChickenSamosa. It would look something like this:
Although this code works, you see the problem with supporting a new type of Samosa, say, Chicken Samosa. We would need to write another method inside our main class thus disrupting the entire code. This requires the entire program with 10s of classes to be re-compiled even for one change in one class. Having it separated would give us the ability to compile/re-compile just the class that we want. Also, its ties together the abstraction and implementation together which is always a bad practice.
Now let’s rewrite this code using the principles of Bridge Design Pattern.
At the risk of repeating myself, the definition provided in the introduction must be a little clearer by now — ‘…to separate implementation specific and implementation independent abstraction.’
See how the abstraction is now achieved neatly providing a platform to easily define and scale the types of Samosas for the future. This pattern also has another ability. Let’s say you hire a new chef who wants to change the recipe for Aloo Samosa to make it more yum, you can do that quite easily without disturbing the entire Samosa classes or other types of Samosas’ code.
Follow our blog series on Design Patterns
1. Learn Factory Design Pattern with Python
2. The Facade Pattern in Python!
3. All about the Adapter design pattern in Python
4. Everything you need to know about Singleton Design Pattern in Python
5. Bridge Design Pattern in Python
I have seen a lot of people, specially in my closed friend circle, wondering about an entry gate to crypto world. Most of the times, these people are from tech background and still lost in the crypt…
tix.africa provides event organizers access to credit through a partnership with CredPal
Nigeria is Nigerian cuisine is rich in protein, carbohydrate and fat. Mainly prepared from about 80% natural ingredients, vegetables, and aromatic spices and herbs all around. Nigeria is home to…