Bridge pattern in C#

Hello everybody,

Today I want to speak about design pattern Bridge. 

Before I'll continue, here is definition of bridge design pattern:

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

Very easy to grasp? For me honestly talking wasn't. 

I propose another definition:

If your class need some kind of functionality that can be changed, you can inject this functionality as interface. And the question you can get for now, after reading my previous post about Adapter is what is difference between adapter and Bridge?

Well, the main difference is that you have access to all code. Or in other words you need adapter, if you have some library, but if you have source code of library and can modify that library, then you can use Bridge designe pattern. 

General UML schema of Bridge design pattern:

Here we have class Abstract class, which aggregates interface Some special interface.

Some special interface has three implementations, Special implementation 1, special implementation 2, special implementation 3.

And we have Abstract class implemenation, which uses one of implementations of some special interface

No Comments

Add a Comment