What is Adapter Category: Structural Also known as ‘Wrapper’

Slides:



Advertisements
Similar presentations
13/04/2015Client-server Programming1 Block 6: Threads 1 Jin Sa.
Advertisements

Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 10: Continuing with classes Constructors, using classes.
Design Patterns Section 7.1 (JIA’s) Section (till page 259) (JIA’s) Section 7.2.2(JIA’s) Section (JIA’s)
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Java Threads Part II. Lecture Objectives To understand the concepts of multithreading in Java To be able to develop simple multithreaded applications.
Patterns – Day 4 Interfaces and Adapter Reminders: Faculty candidate talks Monday and Thursday. No class on Monday.
March Ron McFadyen1 Adapter An adapter converts the interface of a class into another interface clients expect. An adapter lets classes work.
ADAPTER PATTERN Ali Zonoozi Design patterns course Advisor: Dr. Noorhoseini Winter 2010.
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,
Patterns – Day 5 Adapter Reminders: Faculty candidate talk Thursday. No class next Tuesday. Course newsgroup: rhit.cs.patterns.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Factory Method Design Pattern (1) –A creational design.
1 Structural Patterns  How classes and objects are composed to form larger structures  Structural class patterns: use inheritance to compose interfaces.
ADAPTER PATTERN BY Sravanthi Karumanchi. Structure Pattern Structure patterns are concerned with how classes and objects are composed to form large structures.
Java Design Patterns 1 DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY Emil Vassev, Joey Paquet :
Object Adapter Pattern Danny Leavitt. Imagine... You program for the control center of a US phone company. Your network managment software is Object Oriented.
Computer Science 313 – Advanced Programming Topics.
Introduction to Java Class Diagrams. Classes class Account { … } Account.
Insert Category 1 $100 $200 $300 $400 $500 $ 500$500 Insert Category 2 Insert Category 3 Insert Category 4 Insert Category 5.
1 Unit 5 Design Patterns: Design by Abstraction. 2 What Are Design Patterns?  Design patterns are: Schematic descriptions of design solutions to recurring.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES Design patterns.
Computing IV Introduction to Design Pattern Xinwen Fu.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Design Patterns – II Lecture IV. Singleton Pattern Intent – Ensure a class only has one instance, and provide a global point of access to it Motivation.
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Computer Science 313 – Advanced Programming Topics.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAM DESIGN WITH C++ Design patterns.
Session 13 Pinball Game Construction Kit (Version 3):
Class & Object Adapter Patterns (with a focus on Class Adapter) Tim Gutowski CSPP 51023, Winter 2008.
C++ Design Patterns 1 DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY Joey Paquet, Emil Vassev. 2007, 2011, 2013.
Topics Inheritance introduction
What is Iterator Category: Behavioral Generic Way to Traverse Collection Not Related to Collection Implementation Details Not Related to the direction/fashion.
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
Evolve What is a Component? A component is a unit of software that can be instantiated, and uses interfaces to describe which services it provides and.
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.
Structural Patterns C h a p t e r 4 – P a g e 55 StructuralPatterns Design patterns that describe how classes and objects can be combined to form larger.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
Java Memory Management
Structural Patterns How classes and objects are composed to form larger structures Structural class patterns: use inheritance to compose interfaces or.
Design Patterns: Brief Examples
Unit II-Chapter No. : 5- design Patterns
Java Memory Management
Design Patterns C++ Java C#.
By SmartBoard team Adapter pattern.
Design Patterns C++ Java C#.
Adapter Design Pattern
Adapter, Fascade, and More
What is MVC Category: System MVC=Model-View-Controller
by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002
Behavioral and Structural Patterns
Adapter Pattern 1.
Lecture 6 – Exercises TCP1201: 2017/2018.
Advanced Programing practices
What is Singleton Category: Creational pattern
,. . ' ;; '.. I I tI I t : /..: /.. ' : ····t I 'h I.;.; '..'.. I ' :".:".
Structural Pattern part-I introduction
Understanding class definitions
Structural Patterns: Adapter and Bridge
Adapter Design Pattern
The Adapter Pattern.
SE2811 Software Component Design Dr. Rob Hasker
Introduction to Design Patterns
Software Design Lecture : 34.
Expanding the PinBallGame
Adapter Pattern Jim Fawcett
Adapter Pattern Jim Fawcett
Presentation transcript:

What is Adapter Category: Structural Also known as ‘Wrapper’ Ties two disparate/dissimilar systems together ‘Adapts’ one object to meet the demands of another object Typically wires two different interfaces/classes together Analogous to the Square Peg/Round Hole metaphor

How to use Adapter Given class Source and class Target, define class Adapter that ties the two together. Class Adapter should implement Target, and take an instance of Source. For each method of Target, execute and adapt results from Source.

From (Stephen Stelting, Olav Maassen, Applied Java™ Patterns) Class Diagram From (Stephen Stelting, Olav Maassen, Applied Java™ Patterns)

Why Adapter Adapter allows two very different systems to work together. Can mold an object to meet many different criteria (many adapters for one object)

Example (taken from UMBC.edu in references) /** * The SquarePeg class. * This is the Target class. */ public class SquarePeg { public void insert(String str) { System.out.println("SquarePeg insert(): " + str); } * The RoundPeg class. * This is the Adaptee class. public class RoundPeg { public void insertIntoHole(String msg) { System.out.println("RoundPeg insertIntoHole(): " + msg); * The PegAdapter class. * This is the Adapter class. * It adapts a RoundPeg to a SquarePeg. * Its interface is that of a SquarePeg. public class PegAdapter extends SquarePeg { private RoundPeg roundPeg; public PegAdapter(RoundPeg peg) {this.roundPeg = peg;} public void insert(String str) { roundPeg.insertIntoHole(str); }

Adapter References (in addition to references in Introduction) http://www.research.umbc.edu/~tarr/dp/lectures/Adapter.pdf