Structural Patterns: Adapter and Bridge

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Matt Klein. Decorator Pattern  Intent  Attach Additional responsibilities to an object by dynamically. Decorators provide a flexible alternative to.
1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
02 - Structural Design Patterns – 1 Moshe Fresko Bar-Ilan University תשס"ח 2008.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Bridge Pattern.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
The Bridge Pattern Guang Hu February Overview MotivationMotivation ParticipantsParticipants  Structure  Applicability  Benefits  Drawbacks 
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Structural Patterns - Page L6-1 PS95&96-MEF-L13-1 Dr. M.E. Fayad Creationa l Paradigm.
Bridge The decoupling of abstraction and implementation.
Chapter 8, Object Design Introduction to Design Patterns
ADAPTER PATTERN Ali Zonoozi Design patterns course Advisor: Dr. Noorhoseini Winter 2010.
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Adapters Presented By Zachary Dea. Definition A pattern found in class diagrams in which you are able to reuse an ‘adaptee’ class by providing a class,
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
Design Pattern – Bridge (Structural) References Yih-shoung Chen, Department of Information Engineering, Feng Chia University,Taiwan, R.O.C. The Bridge.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Chapter 22 Object-Oriented Design
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Design Patterns.
1 Dept. of Computer Science & Engineering, York University, Toronto CSE3311 Software Design Adapter Pattern Façade pattern.
ADAPTER PATTERN BY Sravanthi Karumanchi. Structure Pattern Structure patterns are concerned with how classes and objects are composed to form large structures.
Object Adapter Pattern Danny Leavitt. Imagine... You program for the control center of a US phone company. Your network managment software is Object Oriented.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
SDP Structural Pattern. SDP-2 Structural Patterns Concerned with how classes and objects are composed to form large structures Class Patterns use.
Structural Design Patterns
Structural Pattern: Bridge When the abstract interface and the concrete implementation have been set up as parallel class hierarchies, it becomes difficult.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IV Structural Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns V More Structural Patterns.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
1 Advanced Object-oriented Design – Principles and Patterns Structural Design Patterns.
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
Bridge Bridge is used when we need to decouple an abstraction from its implementation so that the two can vary independently. This type of design pattern.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
S.Ducasse Stéphane Ducasse 1 Decorator.
The Decorator Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Decorator Design Pattern Phillip Shin. Overview Problem Solution Example Key points.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
Adaptor Bridge Composite UNIT-IV1 Repeated key points for Structural Patterns (Intent, Motivation, Also Known As…) Code Examples Reference
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
The Proxy Pattern (Structural) ©SoftMoore ConsultingSlide 1.
By Robert Smith Feb 23,  The normal method of dealing with an abstraction having several implementations is through inheritance.  However, this.
S.Ducasse Stéphane Ducasse 1 Adapter.
The State Design Pattern A behavioral design pattern. Shivraj Persaud
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns: MORE Examples
Design Patterns: Brief Examples
Describe ways to assemble objects to implement a new functionality
Structural Patterns Structural patterns control the relationships between large portions of your applications. Structural patterns affect applications.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University
Factory Patterns 1.
Behavioral Design Patterns
Adapter Design Pattern
Design Patterns with C# (and Food!)
object oriented Principles of software design
Chapter 8, Object Design Introduction to Design Patterns
Adapter Pattern 1.
Object Oriented Design Patterns - Structural Patterns
BRIDGE PATTERN.
Structural Pattern part-I introduction
Adapter Design Pattern
Decorator Pattern.
Adapter Pattern Jim Fawcett
Software Design Lecture 10.
Adapter Pattern Jim Fawcett
Presentation transcript:

Structural Patterns: Adapter and Bridge Presentation by Matt Deckard

Structural Patterns Classes and objects are composed to form larger structures. Class patterns Inheritance Compose interfaces and implementations Object patterns Compose objects Change composition at runtime

Adapter Pattern a.k.a. Wrapper Has both class and object forms Adapts the interface of one class into that of an otherwise incompatible class Use to: make use of a class with incompatible interface create reusable class that will play nice with others use several subclasses without having to subclass each one to adapt their interface (object form)

Adapter Pattern Structure

Adapter Pattern Participants Collaborations Target Client Adaptee defines the domain-specific interface that Client uses Client collaborates with objects conforming to Target interface Adaptee defines existing interface that needs adapting Adapter adapts the interface of Adaptee to the Target interface Collaborations Clients call operations on Adapter instance, which in turn calls the appropriate Adaptee operations

Adapter Pattern Consequences Class form Object form commits to a concrete Adaptee class, so won’t work if we want to adapt a class as well as subclasses (use object form) Adapter can override Adaptee’s behavior introduces only one object; no pointer indirection required Object form allows single Adapter to work with many Adaptee subclasses; can add functionality to all Adaptees at once harder to override Adaptee behvarior – have to subclass Adaptee and make Adapter refer to the subclass

Adapter Pattern Other Issues How much work does Adapter do? simple: changing names of otherwise identical operations complex: supporting new functionality Pluggable Adapters use interface adaptation to make class more reusable Two-way Adapters a class adapter conforms to both incompatible classes use multiple inheritance

Adapter Pattern Implementation Issues Class adapters in C++ adapts publicly from Target and privately from Adaptee Adapter is subtype of Target, not Adaptee Pluggable Adapters Find “narrow” interface – smallest subset of operations Either: make operations abstract in Target for different Adapters to implement put operations in abstract delegate class for different Adapters to subclass

Adapter Pattern Related Patterns Bridge – similar structure, but meant to separate interface from its implementation, rather than change interface of existing object Decorator – enhances object without changing its interface. Thus more transparent and supports recursive composition Proxy – defines surrogate for another object without changing its interface

Bridge Pattern a.k.a. Handle/Body Decouples abstraction from its implementation Use to: avoid binding abstraction to implementation (i.e. want to choose different implementations at runtime) make both abstraction and implementations independently extensible change implementation or abstraction without impacting clients, or hide them from clients share implementation among clients without letting them know

Bridge Pattern Structure:

Bridge Pattern Participants Collaborations Abstraction defines abstraction’s interface maintains reference to Implementor instance RefinedAbstraction extends interface defined by Abstraction Implementor defines interface for implementation classes typically provides more primitive operations than Abstraction ConcreteImplementor implements Implementor interface Collaborations Abstraction forwards client requests to its Implementor object

Bridge Pattern Consequences decouples interface and implementation allows selecting implementation at runtime avoids compilation dependencies on implementation improves extensibility Abstraction and Implementation can be extended independently hides implementation details from clients

Bridge Pattern Implementation Issues for only one implementation, may not need abstract Implementor how, where, and when to choose concrete Implementor? by Abstraction, in its constructor? change at runtime? by another object, like an Abstract Factory? sharing Implementors Handle/Body idiom multiple inheritance combines interface back with implementation

Bridge Pattern Related Patterns Abstract Factory can create and configure Bridges Adapter makes existing unrelated classes work together; whereas Bridge is used in design in effort to avoid needing Adapters later