Presentation is loading. Please wait.

Presentation is loading. Please wait.

by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002

Similar presentations


Presentation on theme: "by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002"— Presentation transcript:

1 by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during your presentation In Slide Show, hold down the control key and click the mouse button Select “Meeting Minder” Select the “Action Items” tab Type in action items as they come up Click OK to dismiss this box This will automatically create an Action Item slide at the end of your presentation with your points entered. Adapter Pattern by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002

2 Scenario Outlets and Plugs
Outlets in the US require a certain type of plug. For example, a plug made in Europe for a European outlet, may not fit in an outlet in the US. To use this appliance in the US, one would need to purchase an adapter. 11/17/2018

3 Overview Structural Patterns
Patterns that describe how we can form larger structures from classes or objects. The Adapter Pattern is a structural pattern which can be a class or an object pattern. Class patterns use inheritance to compose classes. Object patterns use object composition. 11/17/2018

4 Let’s Break it down... This pattern lets classes work together that normally would not because their interfaces were incompatible. Example: TextShape and TextView 11/17/2018

5 Structure of the Adapter Pattern
* 07/16/96 Structure of the Adapter Pattern Object Adapter Example: Target is Shape Client is Drawing Editor Adaptee is TextView Adapter is TextShape 11/17/2018 *

6 Structure of the Adapter Pattern
Class Adapter 11/17/2018

7 Implementation myStack Adapter Pattern is an Object Pattern
abstract class Stack{ abstract Object top(); abstract Object pop(); abstract void push(Object v); } public class myStack { Adapter class private Vector stack = new Vector(); Adaptee object public boolean empty() {return stack.size() == 0;} pubic Object top() {return stack.lastElement();} public Object pop() { Object rslt = stack.lastElement(); stack.removeElementAt(stack.size()-1); return rslt;} void push(Object v) {stack.addElement(v);} Target class 11/17/2018

8 Implementation continued
myStudent Adapter Pattern is a Class Adapter abstract class Student{ Target class abstract void enroll(); ... } public class ArchaicStudent{ Adaptee class public void xyz(){ public class myStudent extends ArchaicStudent{ Adapter class public void enroll(){ this.xyz(); 11/17/2018


Download ppt "by Manish Shah & Eugene Park CSPP 523 Jan.21, 2002"

Similar presentations


Ads by Google