Contents tagged with design patterns
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 … more
today I want to make post about one of design patterns which is called Adapter. There are many articles over the web about this topic, but I hope to bring some clarity in this area.
Before I proceed any further, let me describe situation, when you can need it. One of the cases for consideration can be option, if you have your own class, let's name it A. And then let's say that there is some other class B, which has some needed function for you. For example like this:
How you can deal with this? One of the common ways which many people do, is to use class be directly in your code. For example like this:
Aggregate class B from class A in some kind of function, and do … more