Skip to Content.
Sympa Menu

gang-of-4-patterns - Re: [gang-of-4-patterns] what is the diffence in adapter and bridge patterns

gang-of-4-patterns AT lists.cs.illinois.edu

Subject: Design Patterns discussion

List archive

Re: [gang-of-4-patterns] what is the diffence in adapter and bridge patterns


Chronological Thread 
  • From: Michael Schuerig <schuerig AT acm.org>
  • To: gang-of-4-patterns AT cs.uiuc.edu
  • Subject: Re: [gang-of-4-patterns] what is the diffence in adapter and bridge patterns
  • Date: Tue, 20 Jul 2004 23:38:12 +0200
  • List-archive: <http://mail.cs.uiuc.edu/pipermail/gang-of-4-patterns>
  • List-id: Design Patterns discussion <gang-of-4-patterns.cs.uiuc.edu>

On Monday 19 July 2004 06:40, Devaiah Doni wrote:

> i could not find the difference in this two patterns..
> only definition is changed..but in the implementation both looks
> same.

Adapter wraps another interface around an already existing object. The
adapter itself is concrete.

Bridge, on the other hand, allows for different realizations of an
abstraction. The main point here is *not* that you have an interface
and various implementing classes. Rather, what you have is an abstract
base class (GOF: Window) and various derived classes; the left-hand
side in the GOF class diagram for Bridge. The point, then, is that the
methods implemented in the abstract base class are realized by
delegation to another object, the Implementor (GOF: WindowImp). The
Implementor, in turn, is an interface with possibly several concrete
implementing classes.

In the GOF example, there are two derived window classes, IconWindow and
TransientWindow. These concrete classes extend the abstract base class
Window and use the provided concrete methods. How these concrete
methods are implemented is not fixed, rather it is defined by the
concrete WindowImp object, which may even be dynamically exchanged.

In effect, Bridge is a way to exchange the implementation of a base
class.

Michael

--
Michael Schuerig The Fifth Rider of the Apocalypse
mailto:michael AT schuerig.de
is a programmer.
http://www.schuerig.de/michael/





Archive powered by MHonArc 2.6.16.

Top of Page