1

I'm reading GoF's Design Patterns and I'm stuck at the Bridge pattern. I can't help but notice it's very similar to the Adapter pattern and I've tried understanding the difference between the two by reading the question on Stack Overflow, but I'm still very confused.

The chapter about the Adapter pattern says that there are two ways to implement it. First, class adapter and second, object adapter. One of the benefits of the object adapter (as written in the book) is that you can adapt not only one particular class, but the children classes as well.

Correct me if I'm wrong, but isn't that kind of Adapter implementation pretty much what Bridge actually is? In other words, isn't Bridge just the object-implemented version of Adapter pattern where you can use the children classes as well?

Thanks.

p.s. If you're going to post a code example, please post it in C++.

Momonga
  • 1,843
  • 2
  • 15
  • 13
  • possible duplicate of [Difference between Bridge pattern and adapter pattern](http://stackoverflow.com/questions/1425171/difference-between-bridge-pattern-and-adapter-pattern) – AllTooSir Jul 13 '13 at 15:19
  • Definitely a duplicate. The answer is perfectly serviceable for this question. – andy256 Jul 14 '13 at 12:37
  • I think my question is a little more specific. The answer you linked doesn't really show me whether there is any difference between the Bridge pattern and the object-implemented Adapter pattern. It is quite informative, but lacks a little bit of further explanation about the Bridge pattern. I hope it makes sense! Thanks. :) – Momonga Jul 14 '13 at 17:18
  • The difference is in the idea behind. Adapter adapts one interface for the client's code requirements. Bridge is the way of design in which you can separate abstraction and implementation. So even if you have the same class diagram as the result of both - those patterns have different background. I think it is proper to say that the bridge is implemented using the 'object adapter'. – Łukasz Rzeszotarski Sep 02 '13 at 18:42

1 Answers1

2

The Bridge wraps the object it represents, but can choose to change that object during runtime for any other object with the same Interface, changing the entire behavior of the Bridge object if needed. The Adapter is usually created for one specific Class and one specific object.

Gtamcn
  • 23
  • 4