Patterns – Day 6 Adapter continued Reminders: Faculty candidate talk today 4:20 PM O-167. No class next Tuesday. Course newsgroup: rhit.cs.patterns.

Slides:



Advertisements
Similar presentations
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
Advertisements

Object Oriented Programming Lecture 7: Algorithm animation using strategy and factory patterns, The Adapter design pattern
Patterns – Day 13 Responsibility Read chapters 6-11 of Metsker. If you have not given me an electronic copy of your (past) presentation, please do so.
Prototype8-1 Prototype CS490 Design Patterns Alex Lo, Rose-Hulman Institute May 13, 2003.
INTERPRETER Main Topics What is an Interpreter. Why should we learn about them.
Patterns – Day 9 Façade Composite Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory Another talk on Monday!
Patterns – Day 8 Adapter continued Facade Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory No class tomorrow.
Bridge The decoupling of abstraction and implementation.
Patterns – Day 4 Interfaces and Adapter Reminders: Faculty candidate talks Monday and Thursday. No class on Monday.
Factory Method Joey Richey Kevin Gorski. Definition Allows a class developer define the interface for creating an object while retaining control of which.
Patterns – Day 10 Composite Responsibility Reminder: Faculty candidate talk Today 4:20 PM O-267. Salman Azhar: Optimal Prediction via Data Compression.
Visitor Matt G. Ellis. Intent Metsker: Let developers define a new operation for a hierarchy without changing the hierarchy classes. GoF: Represent an.
ADAPTER PATTERN Ali Zonoozi Design patterns course Advisor: Dr. Noorhoseini Winter 2010.
Algorithm Programming Exercise 4 Bar-Ilan University תשס"ז by Moshe Fresko.
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Patterns – Day 11 Reminder: Faculty candidate talk Today 4:20 PM O-157. Salman Azhar: Optimal Prediction via Data Compression Read chapters 6-11 of Metsker.
Patterns – Day 5 Adapter Reminders: Faculty candidate talk Thursday. No class next Tuesday. Course newsgroup: rhit.cs.patterns.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
The course builder architecture & project planning presented by: Bahareh Agha Jafari.
Pattern Abstract Factory
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Factory Method Design Pattern (1) –A creational design.
Design Patterns.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Model-View-Controller Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Unit 4 Prototype Summary prepared by Kirk Scott 1.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Unit 10 Adapter Summary prepared by Kirk Scott 1.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Review Class Inheritance, Abstract, Interfaces, Polymorphism, GUI (MVC)
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Class & Object Adapter Patterns (with a focus on Class Adapter) Tim Gutowski CSPP 51023, Winter 2008.
More Design Patterns From: Shalloway & Trott, Design Patterns Explained, 2 nd ed.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
The Bridge Pattern (Structural) “All problems in computer science can be solved by another level of indirection.” – Butler Lampson ©SoftMoore ConsultingSlide.
(c) University of Washington02-1 CSC 143 Java Object and Class Relationships: Interfaces Reading: Ch. 9 (on Java interfaces)
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
The Decorator Pattern (Structural) ©SoftMoore ConsultingSlide 1.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
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.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
S.Ducasse Stéphane Ducasse 1 Adapter.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Presented by FACADE PATTERN
Summary prepared by Kirk Scott
Summary prepared by Kirk Scott
Design Patterns Lecture part 2.
Factory Patterns 1.
Software Design and Architecture
Doug Jeffries CS490 Design Patterns May 1, 2003
Jim Fawcett CSE776 – Design Patterns Summer 2003
Adapter Pattern 1.
Object Oriented Design Patterns - Structural Patterns
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Structural Patterns: Adapter and Bridge
Adapter Design Pattern
The Adapter Pattern.
Decorator Pattern.
Presentation transcript:

Patterns – Day 6 Adapter continued Reminders: Faculty candidate talk today 4:20 PM O-167. No class next Tuesday. Course newsgroup: rhit.cs.patterns

Questions, comments, rebuttals, etc.?

Adapter Pattern GoF Definition: Intent: Convert the interface of a class into another interface that clients expect. Adapter lets classes work together that otherwise couldn’t because of incompatible interface. Also known as Wrapper. Metsker Definition: provide the services the client expects, using the services of a class that has a different interface.

Oozinoz example This is a “Class adapter” public interface RocketSim { abstract Length apogee(); public Force thrust(); }

CHALLENGE 3.1 Complete the class diagram in Figure 3.2 to show the design of a ShellAsRocket class that lets a Shell object participate in a simulation as a RocketSim object.Figure 3.2 This ShellAsRocket class relies on fireworks physics that can model a shell's apogee and "thrust" from its muzzle velocity.

CHALLENGE solution Complete the class diagram in Figure 3.2 to show the design of a ShellAsRocket class that lets a Shell object participate in a simulation as a RocketSim object.Figure 3.2 This ShellAsRocket class relies on fireworks physics that can model a shell's apogee and "thrust" from its muzzle velocity.

Object Adapter example The previous example is a class adapter, since ShellAsRocket extends Shell. Now we look at Metsker’s object adapter example. A class that requires you to write an object adapter is the JTable class in javax.swing. This class creates a GUI (graphical user interface) table component filled with the information that your adapter feeds to it.GUIgraphical user interface To display data from your domain, JTable provides constructors that accept an instance of the TableModel interface.

The AbstractTableModel class provides defaults for all but a few of the methods in TableModel.

CHALLENGE 3.2 CHALLENGE 3.2 Fill in the code for the RocketTable methods that adapt an array of Rocket objects to serve as a TableModel.

Unforseen Adaptation Adaptation is easy when the client plans for it. In Metsker’s example, we have a situation where we can redirect “standard” output to a PrintStream that is different than System.out. –What if we wish to redirect to a JTextArea? CHALLENGE 3.3CHALLENGE 3.3 Write down a comment explaining what might go wrong with this approach to adaptation. CHALLENGE 3.4CHALLENGE 3.4 You'd like to narrow the responsibility of the MessageAdapter class with a specification of the calls the client might make to it. What request should you make?