SlideShare a Scribd company logo
Design Pattern
Bridge Pattern
A Structural design pattern




                              Copyright © Astha
The Problem
Suppose a task has been given of writing a program that will draw rectangles
with either of two drawing programs. It also have been told that when
instantiate a rectangle, it will know whether it should use drawing program 1
(DP1) or drawing program 2 (DP2).

The rectangles are defined as two pairs of points, as represented in the
following figure. The differences between the drawing programs are
summarized
in Table below.
                                                     X2, Y2




           X1, Y1
                                                 Copyright © Astha
The Problem
                      DP1                   DP2
 Used to draw a       draw_a_line( x1,      drawline( x1, x2,
 line                 y1, x2, y2)           y1, y2)
 Used to draw a       draw_a_circle( x, y, drawcircle( x, y, r)
 circle               r)


we don’t want the code that draws the rectangles to worry about what
type of drawing program it should use. It occurs to me that because the
rectangles are told what drawing program to use when instantiated, I can
have two different kinds of rectangle objects: one that uses DP1 and one
that uses DP2. Each would have a draw method but would implement it
differently.




                                             Copyright © Astha
The Problem




              Copyright © Astha
The Problem
A straightforward approach: implementing two shapes and two
drawing programs.




                                       Copyright © Astha
The Problem
Bridge in Action




                   Copyright © Astha
Intent
Decouple an abstraction from its implementation so that the two can vary
independently.




                                              Copyright © Astha
Applicability
Use the Bridge pattern when
 you want to avoid a permanent binding between an abstraction and its
implementation. This might be the
case, for example, when the implementation must be selected or switched at
run-time.
 both the abstractions and their implementations should be extensible by
subclassing. In this case, the Bridge
pattern lets you combine the different abstractions and implementations and
extend them independently.
 changes in the implementation of an abstraction should have no impact on
clients; that is, their code should
not have to be recompiled.




                                               Copyright © Astha
Structure




            Copyright © Astha
Participants
• Abstraction (Window)
    o defines the abstraction's interface.
    o maintains a reference to an object of type Implementor.
• RefinedAbstraction (IconWindow)
    o Extends the interface defined by Abstraction.
• Implementor (WindowImp)
    o defines the interface for implementation classes. This interface doesn't
    have to correspond exactly to Abstraction's interface; in fact the two
    interfaces can be quite different. Typically the Implementor interface
    provides only primitive operations, and Abstraction defines higher-level
    operations based on these primitives.
• ConcreteImplementor (XWindowImp, PMWindowImp)
    o implements the Implementor interface and defines its concrete
    implementation.




                                                Copyright © Astha
Collaborations
• Abstraction forwards client requests to its Implementor object.




                                               Copyright © Astha
Consequences
   Decoupling interface and implementation. An implementation is not bound
    permanently to an interface. The implementation of an abstraction can be
    configured at run-time. It's even possible for an object to change its
    implementation at run-time.
   Improved extensibility. You can extend the Abstraction and Implementor
    hierarchies independently.
   Hiding implementation details from clients. You can shield clients from
    implementation details, like the sharing of Implementor objects and the
    accompanying reference count mechanism (if any).




                                                Copyright © Astha
Implementation
1. Only one Implementor. In situations where there's only one implementation,
   creating an abstract Implementor class isn't necessary. This is a degenerate
   case of the Bridge pattern; there's a one-to-one relationship between
   Abstraction and Implementor. Nevertheless, this separation is still useful
   when a change in the implementation of a class must not affect its existing
   clients—that is, they shouldn't have to be recompiled, just relinked.
2. Creating the right Implementor object. How, when, and where do you decide
   which Implementor class to instantiate when there's more than one?




                                                 Copyright © Astha
Assignment
A document viewer has been made for an enterprise solution (desktop
application), which supports viewing of some specific types of documents. The
supporting types are HTML, Microsoft Word and Microsoft Excel.

Underneath, the document viewer uses an abstract interface of the document
which contains methods to show the document in the viewer.

Now the enterprise application is going to have a web solution where there
would be another document viewer (different in several aspects from the
existing one) with the same functionalities as it is now in the desktop version.

Use the Bridge pattern to solve the problem in such a way that new document
types can be easily incorporated into the system and new type of document
viewer can also be incorporated.




                                                 Copyright © Astha

More Related Content

What's hot

Prototype Design Pattern
Prototype Design PatternPrototype Design Pattern
Prototype Design Pattern
melbournepatterns
 
Presentation facade design pattern
Presentation facade design patternPresentation facade design pattern
Presentation facade design pattern
Bayu Firmawan Paoh
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
Shakil Ahmed
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
melbournepatterns
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
Shakil Ahmed
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
Mudasir Qazi
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
Jyaasa Technologies
 
Composite pattern
Composite patternComposite pattern
Composite pattern
Shakil Ahmed
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
Builder design pattern
Builder design patternBuilder design pattern
Prototype Pattern
Prototype PatternPrototype Pattern
Prototype Pattern
Ider Zheng
 
Abstract Factory Pattern
Abstract Factory PatternAbstract Factory Pattern
Abstract Factory Pattern
guestcb0002
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
VishalChavan83
 
Design pattern
Design patternDesign pattern
Design pattern
Thibaut De Broca
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Rothana Choun
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
MUHAMMAD FARHAN ASLAM
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Shahriar Hyder
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
Guillermo Daniel Salazar
 

What's hot (20)

Prototype Design Pattern
Prototype Design PatternPrototype Design Pattern
Prototype Design Pattern
 
Presentation facade design pattern
Presentation facade design patternPresentation facade design pattern
Presentation facade design pattern
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Builder design pattern
Builder design patternBuilder design pattern
Builder design pattern
 
Prototype Pattern
Prototype PatternPrototype Pattern
Prototype Pattern
 
Abstract Factory Pattern
Abstract Factory PatternAbstract Factory Pattern
Abstract Factory Pattern
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
 
Design pattern
Design patternDesign pattern
Design pattern
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
 

Viewers also liked

20120420 - Design pattern bridge
20120420 - Design pattern bridge20120420 - Design pattern bridge
20120420 - Design pattern bridge
LearningTech
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility Pattern
Hélio Costa e Silva
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
Shakil Ahmed
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
Geoff Burns
 
Command pattern
Command patternCommand pattern
Command pattern
Shakil Ahmed
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility Pattern
Hüseyin Ergin
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
guy_davis
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - AdapterManoj Kumar
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statistics
Rajesh Gunesh
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
Adeel Riaz
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
ProdigyView
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of Data
Adeel Riaz
 

Viewers also liked (14)

Bridge Pattern Derek Weeks
Bridge Pattern   Derek WeeksBridge Pattern   Derek Weeks
Bridge Pattern Derek Weeks
 
Bridge Pattern
Bridge PatternBridge Pattern
Bridge Pattern
 
20120420 - Design pattern bridge
20120420 - Design pattern bridge20120420 - Design pattern bridge
20120420 - Design pattern bridge
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility Pattern
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
 
Command pattern
Command patternCommand pattern
Command pattern
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statistics
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of Data
 

Similar to Bridge pattern

Design Patterns By Sisimon Soman
Design Patterns By Sisimon SomanDesign Patterns By Sisimon Soman
Design Patterns By Sisimon SomanSisimon Soman
 
How to design an application correctly ?
How to design an application correctly ?How to design an application correctly ?
How to design an application correctly ?
Guillaume AGIS
 
EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design Patterns
Haytham Ghandour
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
Utilizing Layers in AutoCAD Prototype Package
Utilizing Layers in AutoCAD Prototype PackageUtilizing Layers in AutoCAD Prototype Package
Utilizing Layers in AutoCAD Prototype PackageBrian Mitchell
 
Technical-design-for-Angular-apps.pdf
Technical-design-for-Angular-apps.pdfTechnical-design-for-Angular-apps.pdf
Technical-design-for-Angular-apps.pdf
SakthivelPeriyasamy6
 
React Workshop
React WorkshopReact Workshop
React Workshop
GDSC UofT Mississauga
 
NX training Report
NX training ReportNX training Report
NX training Report
STAY CURIOUS
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISEsreeja_rajesh
 
Polyline download and visualization over terrain models
Polyline download and visualization over terrain modelsPolyline download and visualization over terrain models
Polyline download and visualization over terrain models
graphitech
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patterns
pradeepkothiyal
 
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming ParadigmProgramming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
Mahmoud Samir Fayed
 
The Big Picture - Integrating Buzzwords
The Big Picture - Integrating BuzzwordsThe Big Picture - Integrating Buzzwords
The Big Picture - Integrating Buzzwords
Alessandro Giorgetti
 
INTERSHIP PPT.pptx
INTERSHIP PPT.pptxINTERSHIP PPT.pptx
INTERSHIP PPT.pptx
AminMemon7
 
A Uniform Specification Of Mixed Reality Interface Components
A Uniform Specification Of Mixed Reality Interface ComponentsA Uniform Specification Of Mixed Reality Interface Components
A Uniform Specification Of Mixed Reality Interface Components
Nicole Heredia
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 

Similar to Bridge pattern (20)

Design Patterns By Sisimon Soman
Design Patterns By Sisimon SomanDesign Patterns By Sisimon Soman
Design Patterns By Sisimon Soman
 
How to design an application correctly ?
How to design an application correctly ?How to design an application correctly ?
How to design an application correctly ?
 
EMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design PatternsEMC Documentum xCP 2.0 Design Patterns
EMC Documentum xCP 2.0 Design Patterns
 
Ch08lect2 ud
Ch08lect2 udCh08lect2 ud
Ch08lect2 ud
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
Utilizing Layers in AutoCAD Prototype Package
Utilizing Layers in AutoCAD Prototype PackageUtilizing Layers in AutoCAD Prototype Package
Utilizing Layers in AutoCAD Prototype Package
 
Technical-design-for-Angular-apps.pdf
Technical-design-for-Angular-apps.pdfTechnical-design-for-Angular-apps.pdf
Technical-design-for-Angular-apps.pdf
 
React Workshop
React WorkshopReact Workshop
React Workshop
 
NX training Report
NX training ReportNX training Report
NX training Report
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
 
Polyline download and visualization over terrain models
Polyline download and visualization over terrain modelsPolyline download and visualization over terrain models
Polyline download and visualization over terrain models
 
Prophecy Of Design Patterns
Prophecy Of Design PatternsProphecy Of Design Patterns
Prophecy Of Design Patterns
 
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming ParadigmProgramming Without Coding Technology (PWCT) Features - Programming Paradigm
Programming Without Coding Technology (PWCT) Features - Programming Paradigm
 
The Big Picture - Integrating Buzzwords
The Big Picture - Integrating BuzzwordsThe Big Picture - Integrating Buzzwords
The Big Picture - Integrating Buzzwords
 
Q Cad Presentation
Q Cad PresentationQ Cad Presentation
Q Cad Presentation
 
INTERSHIP PPT.pptx
INTERSHIP PPT.pptxINTERSHIP PPT.pptx
INTERSHIP PPT.pptx
 
Presentation on
Presentation on Presentation on
Presentation on
 
Presentation
Presentation Presentation
Presentation
 
A Uniform Specification Of Mixed Reality Interface Components
A Uniform Specification Of Mixed Reality Interface ComponentsA Uniform Specification Of Mixed Reality Interface Components
A Uniform Specification Of Mixed Reality Interface Components
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 

More from Shakil Ahmed

Algorithm
AlgorithmAlgorithm
Algorithm
Shakil Ahmed
 
B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-tree
Shakil Ahmed
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
Shakil Ahmed
 
Observer pattern
Observer patternObserver pattern
Observer pattern
Shakil Ahmed
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
Shakil Ahmed
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
Shakil Ahmed
 
iOS 5
iOS 5iOS 5
Ios development
Ios developmentIos development
Ios development
Shakil Ahmed
 
Graph
GraphGraph
Lowest common ancestor
Lowest common ancestorLowest common ancestor
Lowest common ancestor
Shakil Ahmed
 
Segment tree
Segment treeSegment tree
Segment tree
Shakil Ahmed
 
Tree & bst
Tree & bstTree & bst
Tree & bst
Shakil Ahmed
 
Trie tree
Trie treeTrie tree
Trie tree
Shakil Ahmed
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Shakil Ahmed
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
Shakil Ahmed
 

More from Shakil Ahmed (15)

Algorithm
AlgorithmAlgorithm
Algorithm
 
B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-tree
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 
iOS 5
iOS 5iOS 5
iOS 5
 
Ios development
Ios developmentIos development
Ios development
 
Graph
GraphGraph
Graph
 
Lowest common ancestor
Lowest common ancestorLowest common ancestor
Lowest common ancestor
 
Segment tree
Segment treeSegment tree
Segment tree
 
Tree & bst
Tree & bstTree & bst
Tree & bst
 
Trie tree
Trie treeTrie tree
Trie tree
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
 

Recently uploaded

Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

Bridge pattern

  • 1. Design Pattern Bridge Pattern A Structural design pattern Copyright © Astha
  • 2. The Problem Suppose a task has been given of writing a program that will draw rectangles with either of two drawing programs. It also have been told that when instantiate a rectangle, it will know whether it should use drawing program 1 (DP1) or drawing program 2 (DP2). The rectangles are defined as two pairs of points, as represented in the following figure. The differences between the drawing programs are summarized in Table below. X2, Y2 X1, Y1 Copyright © Astha
  • 3. The Problem DP1 DP2 Used to draw a draw_a_line( x1, drawline( x1, x2, line y1, x2, y2) y1, y2) Used to draw a draw_a_circle( x, y, drawcircle( x, y, r) circle r) we don’t want the code that draws the rectangles to worry about what type of drawing program it should use. It occurs to me that because the rectangles are told what drawing program to use when instantiated, I can have two different kinds of rectangle objects: one that uses DP1 and one that uses DP2. Each would have a draw method but would implement it differently. Copyright © Astha
  • 4. The Problem Copyright © Astha
  • 5. The Problem A straightforward approach: implementing two shapes and two drawing programs. Copyright © Astha
  • 6. The Problem Bridge in Action Copyright © Astha
  • 7. Intent Decouple an abstraction from its implementation so that the two can vary independently. Copyright © Astha
  • 8. Applicability Use the Bridge pattern when  you want to avoid a permanent binding between an abstraction and its implementation. This might be the case, for example, when the implementation must be selected or switched at run-time.  both the abstractions and their implementations should be extensible by subclassing. In this case, the Bridge pattern lets you combine the different abstractions and implementations and extend them independently.  changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have to be recompiled. Copyright © Astha
  • 9. Structure Copyright © Astha
  • 10. Participants • Abstraction (Window) o defines the abstraction's interface. o maintains a reference to an object of type Implementor. • RefinedAbstraction (IconWindow) o Extends the interface defined by Abstraction. • Implementor (WindowImp) o defines the interface for implementation classes. This interface doesn't have to correspond exactly to Abstraction's interface; in fact the two interfaces can be quite different. Typically the Implementor interface provides only primitive operations, and Abstraction defines higher-level operations based on these primitives. • ConcreteImplementor (XWindowImp, PMWindowImp) o implements the Implementor interface and defines its concrete implementation. Copyright © Astha
  • 11. Collaborations • Abstraction forwards client requests to its Implementor object. Copyright © Astha
  • 12. Consequences  Decoupling interface and implementation. An implementation is not bound permanently to an interface. The implementation of an abstraction can be configured at run-time. It's even possible for an object to change its implementation at run-time.  Improved extensibility. You can extend the Abstraction and Implementor hierarchies independently.  Hiding implementation details from clients. You can shield clients from implementation details, like the sharing of Implementor objects and the accompanying reference count mechanism (if any). Copyright © Astha
  • 13. Implementation 1. Only one Implementor. In situations where there's only one implementation, creating an abstract Implementor class isn't necessary. This is a degenerate case of the Bridge pattern; there's a one-to-one relationship between Abstraction and Implementor. Nevertheless, this separation is still useful when a change in the implementation of a class must not affect its existing clients—that is, they shouldn't have to be recompiled, just relinked. 2. Creating the right Implementor object. How, when, and where do you decide which Implementor class to instantiate when there's more than one? Copyright © Astha
  • 14. Assignment A document viewer has been made for an enterprise solution (desktop application), which supports viewing of some specific types of documents. The supporting types are HTML, Microsoft Word and Microsoft Excel. Underneath, the document viewer uses an abstract interface of the document which contains methods to show the document in the viewer. Now the enterprise application is going to have a web solution where there would be another document viewer (different in several aspects from the existing one) with the same functionalities as it is now in the desktop version. Use the Bridge pattern to solve the problem in such a way that new document types can be easily incorporated into the system and new type of document viewer can also be incorporated. Copyright © Astha