BTS530: Major Project Planning and Design The Composite Pattern All References and Material From: Design Patterns,by (GOF!) E.Gamma, R.Helm, R.Johnson,

Slides:



Advertisements
Similar presentations
AP 04/02 Structural Patterns Describe how classes and objects are composed to form larger structures Structural class patterns use inheritance to compose.
Advertisements

1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
Design Patterns Design Patterns Composite Pattern Observer Pattern.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
March Ron McFadyen1 Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat.
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.
The Composite Pattern. Owners (No Twins, Expos) Managers (No Twins, Expos) Congress (No Twins, Expos) Media (No Twins, Expos) Radio (No Twins, Expos)
Chapter 8, Object Design Introduction to Design Patterns
K. Stirewalt CSE 335: Software Design Synthetic OO Design Concepts & Reuse Lecture 2: Abstract classes and composite structures Topics: –Elaboration of.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0More on Structural Patterns - Page L7-1 PS95&96-MEF-L14-1 Dr. M.E. Fayad Creationa.
Software Design and Documentation Individual Presentation: Composite Pattern 9/11/03.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
The Unified Modeling Language (UML) Class Diagrams.
© SERG Software Design (OOD Patterns) Object-Oriented Design Patterns Topics in Object-Oriented Design Patterns Compliments of Spiros Mancoridis Material.
OOMPA Lecture 9 Design Patterns Composite Pattern Observer Pattern.
1 Dept. of Computer Science & Engineering, York University, Toronto Software Development CSE3311 Composite Pattern.
Composite Design Pattern. Motivation – Dynamic Structure.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Composit Pattern.
SE2811 Week 7, Class 1 Composite Pattern Applications Conceptual form Class structure Coding Example Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark.
UML - Patterns 1 Design Patterns. UML - Patterns 2 Becoming Good OO Developers Developing good OO Software is hard Takes a lot of time to take advantage.
3-1 Composite Design Pattern Rick Mercer. 2 Composite Pattern Recurring problem: –Often complex structures are built with container and primitive objects.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
GoF: Document Editor Example Rebecca Miller-Webster.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 8, Object Design: Introduction to Design Patterns.
1 Design Patterns Object-Oriented Design. 2 Design Patterns 4Reuse of design knowledge and experience 4Common in many engineering disciplines 4Avoids.
Composite Pattern ( ) Pattern Hatching Chpt 1-2 Presentation by Joe Barzilai 1/30/2006.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
© SERG Software Design (OOD Patterns) Pg 1 Object-Oriented Design Patterns Topics in Object-Oriented Design Patterns Material drawn from [Gamma95,Coplien95]
The Prototype Pattern (Creational) ©SoftMoore ConsultingSlide 1.
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
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Week 6, Day 3 The Gang of Four and more … A new design pattern SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1.
BTS430 Systems Analysis and Design using UML Design Class Diagrams (ref=chapter 16 of Applying UML and Patterns)
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
Georgia Institute of Technology Comic Strip Analysis and Design Inheritance, Abstract Classes, and Polymorphism part1 Barb Ericson Georgia Institute of.
CS 116 Object Oriented Programming II Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Composite Pattern Himanshu Gupta Shashank Hegde CSE776 – Design Patterns Fall 2011 Good composition is like a suspension bridge - each line adds strength.
WHAT IS A Context Diagram?
Chapter 8 Object Design: Reuse and Patterns 2.
BTS530: Major Project Planning and Design
Object-Orientated Analysis, Design and Programming
Slide design: Dr. Mark L. Hornick
BTS430 Systems Analysis and Design using UML
Composite Pattern SE2811 Software Component Design
Iterator and Composite Design Patterns
UML Class Diagram: class Rectangle
Object-Oriented Design Patterns
More Design Patterns 1.
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.
Chapter 8, Object Design Introduction to Design Patterns
Design Patterns - A few examples
More Design Patterns 1.
Lecture 9 – Design Patterns 2
Design Patterns A Case Study: Designing a Document Editor
Jim Fawcett CSE776 – Design Patterns Summer 2003
Software Development CSE3311
Composite Pattern Context:
Polymorphism Pattern.
13. Composite Pattern SE2811 Software Component Design
Software Design Lecture : 35.
13. Composite Pattern SE2811 Software Component Design
Object Oriented Design
Composite Design Pattern By Aravind Reddy Patlola.
non-chronological report
Software Design Lecture : 36.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Presentation transcript:

BTS530: Major Project Planning and Design The Composite Pattern All References and Material From: Design Patterns,by (GOF!) E.Gamma, R.Helm, R.Johnson, J.Vlissides, Addison-Wesley, 2001

Composite The Problem: How do you treat a group or composition structure of objects the same way (polymorphically) as a non- composite object?

Composite A Suggestion/Solution: Define classes for composite and atomic object so that they implement the same interface.

Composite Classic example: Graphics applications users can group components into larger components which can be grouped to form larger components…and so on. problem: the code must treat primitive and container objects differently even though the user might treat them the same Composite pattern uses recursive composition so clients don’t have to make a distinction Design Patterns, p.163

Graphic draw() add(Graphic g) remove(Graphic) getChild(int) Line draw() Picture draw() add(Graphic g) remove(Graphic) getChild(int) Rectangle draw() Text draw() 1…n forall g in graphics g.draw() add g to list of graphics graphics Design Patterns, p.163

aPicture aLineaRectangle aTextaLineaRectangle Design Patterns, p.164

Component operation() add(Component) remove(Component) getChild(int) Composite operation() add(Component) remove(Component) getChild(int) Leaf operation() 1…n forall c in children c.operation() Client children Design Patterns, p.164

aComposite aLeaf Design Patterns, p.165

Composite Component (Graphic): declares the interface for objects in the composition implements common default behaviour declares an interface for managing child components Leaf (Rectangle, Line, Text) has no children defines behaviour for primitives Composite (Picture) defines behaviour for components having children stores child components implements child-related operations through the component interface Design Patterns, p.165

Composite The Client: uses the Component class interface to interact with objects in the composite structure If recipient is Leaf request handled directly If recipient is Composite request is usually forwarded to child components, possibly performing additional operations before and/or after forwarding Design Patterns, p.165

Composite Exercise draw a sequence diagram to illustrate: draw line l draw circle c group l and c into graphicA draw box b1 draw box b2 group b1 and b2 into graphicB group graphicB into graphicA select c in graphicA (assume lines, circles, boxes exist but not graphics)