[Design Patterns] Adapter and Bridge

V

v4vijayakumar

Adapter makes things work after they're designed; Bridge makes them
work before they are.

what the above statement from [GOF, p219] means?
 
S

sreekanth.ramakrishnan

Adapter makes things work after they're designed; Bridge makes them
work before they are.

what the above statement from [GOF, p219] means?


Hi,

The answer to your question is simple.

Bridge pattern Decouples Abstraction and Implementation. You will be
actually working with the abstraction in your client system. So it will
work as the framework was designed for since abstraction never changes.

http://en.wikipedia.org/wiki/Bridge_pattern

But in an adapter pattern, you introduce a wrapper over your designed
system so that multiple clients can interface. In one style of
implementation you ask clients to adhere to a specific abstraction. In
another you just provide a wrapper for the various abstractions which a
client might need.

http://en.wikipedia.org/wiki/Adapter_pattern


Hope these links and my answer helps u
 
T

Thomas Weidenfeller

v4vijayakumar said:
Adapter makes things work after they're designed; Bridge makes them
work before they are.

what the above statement from [GOF, p219] means?

Actually, this is described in the paragraph before what you have
quoted. To express it in other words:

If you have two existing things which don't fit well together, you use
an Adapter to glue them together.

If you design something from scratch and you know upfront that you have
one or more implementations behind a common abstraction (an interface),
you right from the start design a Bridge to link abstraction and
implementation.

An Adapter is there to cure a symptom (things not fitting together). A
Bridge is a design choice when you want to decouple an abstraction and
an implementation to a certain degree.

The code of an Adapter and a Bridge can look the same. It is the
intention why it was introduced which makes the difference.

/Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top