Design Pattern : Adapter Versus Bridge

Connect with

These two design pattern, i.e. Adapter and Bridge looks similar somewhere but intent of both are different. Here, first letter of both describe about their pattern. Well, be logical and you can link logically/illogically to remember things most of the time , specially if you want to learn for longer period of time :). In Bridge pattern , first letter is ‘B’ means Before design, this pattern which considerable at design time. In Adapter first letter is A means After , it means after design it can be considered. These B and A letter is used here just to keep in mind or you can say learning purpose. Let me explain the similarity and differences between them.

1. Bridge Design Pattern

Decouple an abstraction from its implementation so that the two can vary independently.

2. Adapter Design Pattern

Make 2 different interfaces compatible

Adapter change the Interface , it mean make the 2 different interface compatible.
where it used?
Let me take an example of client code which is your application code and third party library code. If you have a to make 2 different interface retrofitted between them for two different reason.
– first, you don’t want to change your client code , due to fragility nature of code or extensible nature of code which is already in production.
– Second, you don’t have access of third party library which you can not change.

Then, you need to implement class which, implements client interface and compose Adaptee in a class which in-turns make compatible between client and Adaptee.

3. Key Points

  • Adapter and Bridge both used to solve different design issue.
  • Adapter and Bridge both work under concealing the details.
  • Adapter pattern is more of a after design time while Bridge pattern is more of a design time pattern.


4. References

Connect with

Leave a Reply

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