The Bridge Pattern - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

The Bridge Pattern

Description:

Want to avoid a permanent binding between an abstraction and implementation. ... implementation of abstraction - can be configured at run-time ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 16
Provided by: intechsyst
Category:

less

Transcript and Presenter's Notes

Title: The Bridge Pattern


1
The Bridge Pattern
  • Guang Hu
  • February 2002

2
Overview
  • Motivation
  • Participants
  • Structure
  • Applicability
  • Benefits
  • Drawbacks
  • Related Pattern

3
Motivation
4
Motivation
5
Motivation
6
Participants
  • Abstraction (Entry)
  • - define the abstractions interface
  • - maintains a reference to an object of type
  • Implementor
  • Refined Abstraction (Task)
  • - extends the interface defined by
    Abstraction

7
Participants (continue)
  • Implementor (persistentImp)
  • - defines an interface for implementation
  • classes. Typically, this Implementors
  • interface provides only primitive menthod
  • ConcreteImplementor (oraclePImp, AccessPImp)
  • - implements the Implementors interface

8
Structure
9
Applicability
  • Want to avoid a permanent binding between an
    abstraction and implementation.
  • When abstractions and implementations should be
    extensible through subclassing.
  • When implementation changes should not impact
    clients.

10
Applicability (continue)
  • When the implementation should be completely
    hidden from the client. (C)
  • When you have a proliferation of classes.
  • When, unknown to the client, implementations are
    shared among objects.

11
Benefits
  • Avoid permanent binding between an abstraction
    and its implementation
  • Avoid nested generalizations
  • Ease adding new implementations
  • Reduce code repetition
  • Allow runtime switching of behaviour

12
Drawbacks
  • Double indirection
  • - entry operation are implemented by
    subclasses of PersistentImp class. Entry class
    must delegate the message to a PersistentImp
    subclass which implements the appropriate method.
    This will have a slight impact on performance.

13
Consequences
  • decoupling interface implementation
  • - implementation of abstraction - can be
    configured at run-time
  • - eliminate compile time dependencies on
    implementation
  • - encourages layering
  • improved extensibility
  • - Abstraction Implementer - can be extended
    independently
  • hiding implementation details from clients

14
Related Pattern
  • Abstract Factory- The Abstract Factory pattern
    can be used by the Bridge pattern to decide which
    implementation class to instantiate for an
    abstraction object.
  • Adapter

15
Thank you
Write a Comment
User Comments (0)
About PowerShow.com