Bridge Design Pattern

2,069 views

Published on

Presentation on Bridge Design Pattern given by me in Johnston.

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,069
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Bridge Design Pattern

  1. 1. Bridge Pattern -Sahil Kumar
  2. 2. Intent <ul><li>“ Decouple an abstraction from its implementation so that the two can vary independently.” </li></ul><ul><ul><li>Multiple Dependent Implementations. </li></ul></ul><ul><ul><li>Single Independent Interface. </li></ul></ul>
  3. 3. Motivation <ul><li>When an abstraction can have several implementations inheritance is used to accommodate them. </li></ul><ul><li>But inheritance binds an implementation to the abstraction permanently, hence its difficult to modify, extend and reuse abstraction and implementations independently . </li></ul><ul><li>It’s inconvenient to extend the abstraction to cover different kinds of functionalities. </li></ul>
  4. 4. Structure
  5. 5. Participants <ul><li>Abstraction </li></ul><ul><ul><li>defines the abstraction interface </li></ul></ul><ul><ul><li>maintains a reference to an object of type implementor. </li></ul></ul><ul><li>Refined Abstraction </li></ul><ul><ul><li>Extends the interface defined by Abstraction (optional) . </li></ul></ul><ul><li>Implementor </li></ul><ul><ul><li>defines the interface for the implementation classes. </li></ul></ul><ul><li>ConcreteImplementor </li></ul><ul><ul><li>implements the implementor interface and defines its concrete implementation . </li></ul></ul>
  6. 6. Example - Code
  7. 7. Consequences <ul><li>Decoupling interface and implementation. </li></ul><ul><ul><li>An implementation is not bound permanently to the interface. The implementation of an abstraction can be configured at run time. </li></ul></ul><ul><li>Improved Extensibility </li></ul><ul><ul><li>You can extend the Abstraction and Implementation hierarchies independently. </li></ul></ul><ul><li>Hiding Implementation details from the client. </li></ul><ul><ul><li>You can shield clients from implementation details like the sharing of implementor objects. </li></ul></ul>
  8. 8. The .Net Run-time is a Bridge <ul><li>C#, Visual Basic, Managed C++ are all abstractions </li></ul><ul><li>MSIL is the implementation </li></ul><ul><li>Mono and dotGnu are other implementations </li></ul>
  9. 9. <ul><li>// thank you… </li></ul><ul><li>Console.WriteLine(“ Questions? ”); </li></ul><ul><li>Console.ReadLine(); </li></ul>

×