Structural Design Pattern: CLASS ADAPTER a.k.a. WRAPPER By Ed Kim.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Copyright A. Andrews, 2003 Regression Testing Department of Computer Science.
JDBC Session 4 Tonight: Design Patterns 1.Introduction To Design Patterns 2.The Factory Pattern 3.The Facade Pattern Thursday & Next Tuesday: Data Access.
1 Layers Data from IBM-Rational and Craig Larman’s text integrated into these slides. These are great references… Slides from these sources have been modified.
© Copyright 2011 John Wiley & Sons, Inc.
Specification and Implementation Separating the specification from implementation makes it easier to modify programs. Changes in the class’s implementation.
Week 8 Implementation Design Alex Baker. Implementation Design System Design – Describes what the system should do Implementation Design – Describes what.
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
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,
© M.E. Fayad SJSU -- CmpE Analysis Heuristics Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
Façade Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Objektorienteret netværkskommunikation Presentation: Architectures for Distributed Systems.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 14Slide 1 Design with Reuse l Building software from reusable components.
UML - Development Process 1 Software Development Process Using UML (2)
An Extension to XML Schema for Structured Data Processing Presented by: Jacky Ma Date: 10 April 2002.
Design Patterns.
Object Oriented Analysis and Design Introduction.
1 Dept. of Computer Science & Engineering, York University, Toronto CSE3311 Software Design Adapter Pattern Façade pattern.
Requirements Engineering meets UML 1st. September 2007 Richard Farr, Cybernetic Intelligence GmbH.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Object Adapter Pattern Danny Leavitt. Imagine... You program for the control center of a US phone company. Your network managment software is Object Oriented.
Modular Programming. Modular Programming (1/6) Modular programming  Goes hand-in-hand with stepwise refinement and incremental development  Makes the.
Computer Science 313 – Advanced Programming Topics.
Unit 4 Prototype Summary prepared by Kirk Scott 1.
CSC 395 – Software Engineering Lecture 12: Reusability –or– Programming was Bjarne Again.
Department of Computer Science, York University Object Oriented Software Construction 13/10/ :44 AM 0 CSE3311 – Software Design Adapter Pattern.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 05. Review Software design methods Design Paradigms Typical Design Trade-offs.
CBSE 2014 Modeling Components with UML. Bibliography Modelling components in UML – Main text: Kim Hamilton, Russell Miles, Learning UML 2.0, OReilly,
Structural Design Patterns
Page 1© Crown copyright 2004 FLUME Metadata Steve Mullerworth 3 rd -4 th October May 2006.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Chapter 7: The Adapter Pattern. Object Oriented Adapters Suppose that you have existing software. You have outsourced some of your work and there is a.
 Copyright 2005 Digital Enterprise Research Institute. All rights reserved. Enabling Components Management and Dynamic Execution Semantic.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Java EE Patterns Dan Bugariu.  What is Java EE ?  What is a Pattern ?
Class & Object Adapter Patterns (with a focus on Class Adapter) Tim Gutowski CSPP 51023, Winter 2008.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
More Design Patterns From: Shalloway & Trott, Design Patterns Explained, 2 nd ed.
Adapter and Façade Patterns By Wode Ni and Leonard Bacon-Shone.
計算機程式語言 Lecture 03-1 國立台灣大學生物機電系 林達德 3 3 Introduction to Classes and Objects.
Design Patterns: Structural Design Patterns General and reusable solutions to common problems in software design Software University
Steps to integrate XML How does XML processing work? Simple uses of passive DOM objects Adding behaviour to information A converter and translator subsystem.
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
CS 350 – Software Design The Adapter Pattern – Chapter 7 Gang of Four Definition: Convert the interface of a class into another interface that the client.
S.Ducasse Stéphane Ducasse 1 Adapter.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Broker Design Patterns: Adapters and Proxy.
Architectural Mismatch: Why reuse is so hard? Garlan, Allen, Ockerbloom; 1994.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
CS 265 Jianbo Zhao. What is interface? Interface is a detailed boundary between code that provides a service and code that uses it. An interface defines.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Abstract Factory Pattern
Data Abstraction: The Walls
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Chapter 16 – Software Reuse
CBSE 2014 Modeling Components with UML
Adapter Pattern 1.
Object Oriented Design Patterns - Structural Patterns
Introduction to Cordence Worldwide
Review: Design Pattern Structure
Department of Computer Science Regression Testing.
Structural Patterns: Adapter and Bridge
Adapter Design Pattern
Chapter 16 – Software Reuse
Chapter 8, Design Patterns Introduction
Architectural Mismatch: Why reuse is so hard?
Presentation transcript:

Structural Design Pattern: CLASS ADAPTER a.k.a. WRAPPER By Ed Kim

Context You have discovered a legacy class that provides some or all of the functionality you need but lacks the right interface for a given domain More generally, you would like to create a reusable class that allows classes having incompatible interfaces to work together You may not have access to the source code to modify the interface(s) of the class(es) in question Assuming the source code is accessible, tailoring the class’s interface to a specific application might still a bad idea (e.g., increased coupling, excessive dependencies, reduced modularity, etc.)

The Wrapper Class Present a familiar interface to the client while exploiting the services of an existing class made incompatible by its own interface Calls made to the wrapper interface are mapped to the interface of the adapted class for actual implementation Allows otherwise incompatible classes to work together Existing class source code can remain intact, promoting loose coupling and increased modularity while reducing superfluous dependencies

An Example

The Client Suppose your client is a North American travel iron (NATravelIron). NATravelIron

The Expected Interface Regardless of its physical location, NATravelIron expects to make use of a NEMA 5-15 socket (NEMA515Socket) in order to obtain electricity. NEMA515Socket

The Incompatible Interface… Suppose further that NATravelIron will be traveling for an indefinite period of time with its owner to Italy – a country where only sockets of type CEE 7/16 (CEE716Socket) are to be found. How, then, will NATravelIron continue to function properly abroad? ItalyCEE716Socket

…The Coveted Functionality Clearly, CEE716Socket provides the same power delivery services in Europe that NEMA515Socket would provide in North America (ignoring any voltage discrepancies for the sake of argument), but CEE716Socket simply lacks the appropriate interface that NATravelIron needs to obtain electricity and thus function properly.

The Solution Introduce a North America to Europe travel adapter (NAEUTravelAdapter) that presents the familiar NEMA515Socket interface to NATravelIron while exploiting the CEE716Socket interface to deliver power. NAEUTravelAdapter

UML Model

A C++ Implementation

Header Files

Implementation Files

Tester

Output

Closing Remarks Other issues, which are beyond the scope of this presentation, do exist with respect to class adapter usage – kindly refer to your nearest pattern reference for this information