Patterns – Day 10 Composite Responsibility Reminder: Faculty candidate talk Today 4:20 PM O-267. Salman Azhar: Optimal Prediction via Data Compression.

Slides:



Advertisements
Similar presentations
Formal Methods in Software Engineering
Advertisements

Why am I here Development techniques are headed down the wrong path! Our world should be getting simpler – it is not The solutions that will solve the.
1 Pipelining Part 2 CS Data Hazards Data hazards occur when the pipeline changes the order of read/write accesses to operands that differs from.
Framework is l Reusable Code, often domain specific (GUI, Net, Web, etc) l expressed as l a set of classes and l the way objects in those classes collaborate.
ABSTRACT CLASSES AND INTERFACES. Abstract methods You can declare an object without defining it: Person p; Similarly, you can declare a method without.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott.
Chain of Responsibility Ian Price Dale Willey. We Will Cover What is Chain of Responsibility A few examples The Metsker Challenges.
Fall 2009ACS-3913 Ron McFadyen Composite Pattern Problem: How do we treat a composition structure of objects the same way as a non-composite object? Arises.
LIMITS The Limit of a Function LIMITS In this section, we will learn: About limits in general and about numerical and graphical methods for computing.
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 9 Façade Composite Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory Another talk on Monday!
Deadlocks Vivek Pai / Kai Li Princeton University.
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.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
CSE 115 Week 5 February , Monday Announcements Exam 3 today Exam 3 today Lab 3 due this week Lab 3 due this week Exam 4 Monday 2/18 Exam.
1 Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
Factory Method Joey Richey Kevin Gorski. Definition Allows a class developer define the interface for creating an object while retaining control of which.
Interfaces. In this class, we will cover: What an interface is Why you would use an interface Creating an interface Using an interface Cloning an object.
Patterns – Day 6 Adapter continued Reminders: Faculty candidate talk today 4:20 PM O-167. No class next Tuesday. Course newsgroup: rhit.cs.patterns.
Visitor Matt G. Ellis. Intent Metsker: Let developers define a new operation for a hierarchy without changing the hierarchy classes. GoF: Represent an.
1  2004 Morgan Kaufmann Publishers Chapter Seven.
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.
CS 206 Introduction to Computer Science II 02 / 25 / 2009 Instructor: Michael Eckmann.
Business Modeling Domain Modeling Source: Use Case Driven Object Modeling with UML – A Practical Approach By Doug Rosenberg ISBN:
Composite Design Pattern. Motivation – Dynamic Structure.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
CHAPTER 2 LIMITS AND DERIVATIVES. 2.2 The Limit of a Function LIMITS AND DERIVATIVES In this section, we will learn: About limits in general and about.
Design Patterns in Java Chapter 5 Composite Summary prepared by Kirk Scott 1.
Chapter 1 Object-Oriented Analysis and Design. Disclaimer Slides come from a variety of sources: –Craig Larman-developed slides; author of this classic.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Unit 25 Composite Summary prepared by Kirk Scott 1.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
CS 350 – Software Design The Strategy Pattern – Chapter 9 Changes to software, like other things in life, often focus on the immediate concerns and ignore.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Polymorphism, Abstraction and Virtual Functions. In this slide, we introduce virtual functions and two complex and powerful uses for derived classes that.
What to remember from Chap 13 (Logical architecture)
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Observer Please Snarf the Code for Today’s Class..
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Introduction to Software Architecture.
Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.
Design Patterns David Talby. This Lecture Re-routing method calls Chain of Responsibility Coding partial algorithms Template Method The Singleton Pattern.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
CS 4240: Rethinking Some OOP Ideas and Terms for OOA&D Readings: Chap. 8 in Shalloway and Trott (referred to as S&T in these slides) Wikipedia on information.
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.
Object-Oriented Design Concepts University of Sunderland.
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.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
Object-Oriented Programming: Polymorphism Chapter 10.
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.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
More Interfaces, Dynamic Binding, and Polymorphism
Summary prepared by Kirk Scott
Summary prepared by Kirk Scott
Sequential circuit design
Jim Fawcett CSE776 – Design Patterns Summer 2003
Slides by Steve Armstrong LeTourneau University Longview, TX
Chapter 10 Object States and The Statechart Diagram
Objects First with Java A Practical Introduction using BlueJ
Lesson 5: More on Creational Patterns
Chapter 14 Abstract Classes and Interfaces
Objects First with Java A Practical Introduction using BlueJ
Software Design Lecture : 36.
Message Passing Systems
Presentation transcript:

Patterns – Day 10 Composite Responsibility Reminder: Faculty candidate talk Today 4:20 PM O-267. Salman Azhar: Optimal Prediction via Data Compression Read chapters 6-11 of Metsker.

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.?

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?

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

Responsibility In one sense, responsibility is what OO design and programming are all about. Who is responsible for what? So most patterns will say something about responsibility. In Metsker’s classification, seven of the patterns particularly deal with this.

CHALLENGE 7.1 CHALLENGE 7.1 The class structure shown here has at least ten questionable assignments of responsibility. Circle as many problems as you can find; for four of these points, write a statement of what is wrong.

Responsibility Patterns If you intend toApply the pattern Centralize responsibility in a single instance of a class SingletonSingleton (Chapter 8)Chapter 8 Decouple an object from awareness of which other objects depend on it ObserverObserver (Chapter 9)Chapter 9 Centralize responsibility in a class that oversees how a set of other objects interact MediatorMediator (Chapter 10)Chapter 10 Let an object act on behalf of another object ProxyProxy (Chapter 11)Chapter 11 Allow a request to escalate up a chain of objects until one handles it Chain of Responsibility Chain of Responsibility (Chapter 12)Chapter 12 Centralize responsibility in shared, fine- grained objects FlyweightFlyweight (Chapter 13)Chapter 13