Author - StudySection Post Views - 169 views
Pattern

Bridge Design Pattern

Design patterns provide solutions to the commonly occurring problems in the design of the software. The design pattern is like a blueprint that can be customized to target any particular problem of the code. Patterns are a toolkit of solutions to address common problems in software design. They provide the team with a common language to communicate efficiently.

The bridge pattern separates the implementation from abstraction and makes it easy to modify both independently without any risk of coupling. In this pattern, the user is provided with an interface basically, between abstraction class and implementer classes. With the help of this users can make the changes in any of the classes without hampering the other one.
Design Patterns basically provide the solution to the problems that we encounter doing different types of implementations, each having its own unique Requirement.

This design pattern occurs when we have two different kinds of implementations, whereby one implementation uses the other and we want to progressively add functionality to these implementations.

One way to solve this problem is to keep the dependent implementation inside the client implementation and implement the dependent implementation separately in both classes. The problem with this is that whenever we have to change the client implementation we may end up changing the dependent implementation as well and if the change is dependent implementation-specific we may need all the client implementers.

So, the way to solve this using Bridge Design Pattern is to create separate abstract classes for both kinds of implementation and keep the reference of the dependent implementation inside the client implementation. This way a loose coupling is created between both the implementations, which helps to progressively add functionality to these implementations in an independent manner.

Example:

Suppose we need to draw different shapes and fill them with different colors. So, the usual approach will be to create an interface Shape and create a class Triangle and Square that implements this interface.

Bridge Design

Now Suppose we want to fill them with blue and green colors. So As a typical programmer, we take the next step of creating different classes of triangles and squares with colors.

Design

Now though the approach looks fine, it tightly couples the things, so let’s see how to solve this with a bridge design pattern.

BRIDGE DESIGN PATTERN

Bridge chart

Here, the shape will have a reference to color, and both the shape and the color will extend separately without bothering each other.

StudySection gives an opportunity to beginners and experts in .NET framework to go through StudySection’s .NET certification exam and get a .NET certification for enhancement of career in programming. If you have knowledge of the .NET framework then you can get a certificate through an online exam at StudySection.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri