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!

Slides:



Advertisements
Similar presentations
Schedule and Effort. Planning Big Project: Waterfall-ish Style 1.Figure out what the project entails Requirements, architecture, design 2.Figure out dependencies.
Advertisements

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
Chain of Responsibility Ian Price Dale Willey. We Will Cover What is Chain of Responsibility A few examples The Metsker Challenges.
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.
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.
Fall 2007CS 225 Introduction to Software Design Chapter 1.
Mediator Matt G. Ellis. Overview ► Intent ► Motivation ► Mediators in GUI applications ► Mediators and Relational Integrity ► Conclusion ► Questions.
Factory Method Joey Richey Kevin Gorski. Definition Allows a class developer define the interface for creating an object while retaining control of which.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Façade Pattern Jeff Schott CS590L Spring What is a façade? 1) The principal face or front of a building 2) A false, superficial, or artificial appearance.
Patterns – Day 6 Adapter continued Reminders: Faculty candidate talk today 4:20 PM O-167. No class next Tuesday. Course newsgroup: rhit.cs.patterns.
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.
CS 280 Data Structures Professor John Peterson. Lexer Project Questions? Must be in by Friday – solutions will be posted after class The next project.
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.
Spring 2009CS 225 Introduction to Software Design Chapter 1.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
Pattern Abstract Factory
Composite Design Pattern. Motivation – Dynamic Structure.
1 Some Patterns of Novice Programs Author : Eugene Wallingford ; Dan Steinberg ; Robert Duvall ; Ralph Johnson Source : PLoP 2004 Advisor : Ku-Yaw Chang.
MVC and MVP. References enter.html enter.html
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Design Patterns in Java Chapter 5 Composite Summary prepared by Kirk Scott 1.
©Ian Sommerville 2000 Software Engineering, 6th edition. Slide 1 Component-based development l Building software from reusable components l Objectives.
Introduction to Software Design Chapter 1. Chapter Objectives  To become familiar with the software challenge and the software life cycle  To understand.
Unit 25 Composite Summary prepared by Kirk Scott 1.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
CS 280 Data Structures Professor John Peterson. How Does Parsing Work? You need to know where to start (“statement”) This grammar is constructed so that.
Object-Oriented Analysis and Design Fall 2009.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
3-1 State Design Pattern C Sc 335 Rick Mercer. State Design Pattern State is one of the Behavioral patterns It is similar to Strategy Allows an object.
November Ron McFadyen1 Composite Pattern A composite is a group of objects in which some objects contain others; one object may represent groups,
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IV Structural Patterns.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
M1G Introduction to Programming 2 5. Completing the program.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
The Facade Pattern (Structural) ©SoftMoore ConsultingSlide 1.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Session 30 Final Review. Final Details Wednesday, December 14 at 8 AM Wright 5 (same classroom) Final will be comprehensive Open book Open notes Test.
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
1 CSE 331 Composite Layouts; Decorators slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
CS 350 – Software Design The Decorator Pattern – Chapter 17 In this chapter we expand our e-commerce case study and learn how to use the Decorator Pattern.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
Computer Science 313 – Advanced Programming Topics.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Presented by FACADE PATTERN
Abstract Factory Pattern
Object-Oriented Software Engineering Using UML, Patterns, and Java,
Unified Modeling Language
Section 64 – Manipulating Data Using Methods – Java Swing
Summary prepared by Kirk Scott
Facade Pattern Jim Fawcett CSE776 – Design Patterns Summer 2010
Abstract Factory Pattern
Summary prepared by Kirk Scott
Intent (Thanks to Jim Fawcett for the slides)
Doug Jeffries CS490 Design Patterns May 1, 2003
Creating and Using Classes
Composite Pattern Oct 7, 2003 A composite is a group of objects in which some objects contain others; one object may represent groups, and another.
Jim Fawcett CSE776 – Design Patterns Summer 2003
Program Documentation
Software Design Lecture : 35.
Presentation transcript:

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! Read chapters 6-9 of Metsker.

Student-led discussions on specific patterns Give the basic idea of what the pattern is about. (From different sources if possible) Examples. Metsker’s examples and challenges –As we go through the patterns, we also want to understand the oozinoz framework, because examples in later patterns might depend on them. –The challenge problems often bring out interesting (and sometimes difficult) issues.

Presentations happening soon We’re doing some chapters out of order, so that I don’t do too many in a row. Not ideal, but the best I can do. Be ready on your “earliest day”. It is possible that it will happen later. It is possible that it will be split.

Questions, comments, rebuttals, etc.?

Façade Pattern What is it? What is its purpose? Purpose: To provide a simple interface to services from a complex subsystem.

From wikipedia There may be a large set of objects with broad uses that are used in conjunction to perform a few functions for client objects. The façade pattern provides a simplified interface to achieve only those functions needed without having to reference many different, complicated interfaces. The result is a simple feel to a complicated process.

GoF Compiler Example

Metsker definition a facade is a class with methods that make it easy to use the classes in a subsystem.

Metsker example – dud rockets FlightPanel_1 does too many things: Window for displaying picture Trajectory calculations Application class’ C:\Documents and Settings\anderson\My Documents\Courses\Patterns\o ozinoz\code\com\oozinoz\applic ations\FLightPanel_1.java

Complete the diagram in Figure 4.4 to show the code for FlightPanel_1 refactored into three classes: a FlightPath class, a reduced FlightPanel class that draws a flight path, and a SwingFacade class. Provide the facade with the utility methods that appeared in the initial FlightPanel_1 class. Also provide the facade with a method to launch a frame. Figure 4.4 Challenge 4.1

Complete the diagram in Figure 4.4 to show the code for FlightPanel_1 refactored into three classes: a FlightPath class, a reduced FlightPanel class that draws a flight path, and a SwingFacade class. Provide the facade with the utility methods that appeared in the initial FlightPanel_1 class. Also provide the facade with a method to launch a frame. Figure 4.4 Challenge 4.1-solution

A problem A beginning Java student wants to run a program that requires a line or two of interactive user input. We can give the magic incantations: – BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ); –String oneLine; while( ( oneLine = in.readLine( ) ) != null) but this requires a lot of explanation that the student doesn’t need yet and is probably not ready for. or we can …

Consider this example Run this example: –c:\Documents and Settings\anderson\My Documents\courses\Patterns\Lectures\Facad e\facade –Which classes are involved? –Does Swing provide a façade for this?

A Swing Façade: JOptionPane

JOptionPane Example It is in the class examples directory.

Other façade examples/comments?

Composite Pattern Metsker definition: –A composite is a group of objects in which some objects may contain others; thus, one object may represent groups, and another may represent an individual item, or leafcompositeleaf Examples: –(fill then in)

Advantages of Composite Groups can contain groups or individuals. There can be common behaviors for groups and individuals. Remember slist-recur from PLC? So a group and an individual can present the same interface.

CHALLENGE 5.1CHALLENGE 5.1(Paraphrased) In the main Swing composite example (Component and Container), why are these abstract classes instead of interfaces?

Challenge 5.2 The factory is composed of bays; each bay has one or more manufacturing lines; a line is a collection of machines that collaboratively produce material to meet a schedule. The developers at Oozinoz have modeled this composition from the problem domain with the class structure shown in Figure 5.2.Figure 5.2 As the figure shows, the getMachineCount() behavior applies to both individual machines and collections of machines and returns the number of machines in any given component. CHALLENGE 5.2 CHALLENGE 5.2 Write the code for the getMachineCount() methods implemented by Machine and by MachineComposite.

Additional methods for Machines and MachineComponents MethodBehavior isCompletelyUp() Indicates whether all the machines in a component are in an "up" state stopAll() Directs all the machines in a component to stop processing getOwners() Returns a set of process engineers responsible for the machines in a component getMaterial() Return all the in-process material in a machine component CHALLENGE 5.3 CHALLENGE 5.3 For each method declared by MachineComponent, give recursive definitions for MachineComposite and nonrecursive definitions for Machine.

Non-tree-structured layouts No cycles, but not a tree. What’s the common name for this kind of structure? CHALLENGE 5.4CHALLENGE 5.4 What does the following program print out?

Detecting “non-treeness” CHALLENGE 5.5CHALLENGE 5.5 Write the code for MachineComposite.isTree(Set s). Does that code work if there are cycles in the graph?