Iterator and Composite Design Patterns

Slides:



Advertisements
Similar presentations
January 6. January 7 January 8 January 9 January 10.
Advertisements

Lecture 8 CS203. Implementation of Data Structures 2 In the last couple of weeks, we have covered various data structures that are implemented in the.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Composite Design Pattern (1) –A structural design pattern.
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.
Feb Ron McFadyen1 Iterator Pattern Recall Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate.
The Composite Pattern. Owners (No Twins, Expos) Managers (No Twins, Expos) Congress (No Twins, Expos) Media (No Twins, Expos) Radio (No Twins, Expos)
Iterator Matt G. Ellis. Intent Metsker: Provide a way to access elements of a collection sequentially. GoF: Provide a way to access the elements of an.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Fall 2007ACS Ron McFadyen1 Composite Pattern (see pages ) A composite is a group of objects in which some objects contain others; one object.
Design Patterns. CS351 - Software Engineering (AY2007)Slide 2 Behavioral patterns Suppose we have an aggregate data structure and we wish to access the.
Feb Ron McFadyen1 Iterator Pattern Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate interface.
Winter 2015ACS Ron McFadyen1 Composite Pattern A composite is a group of objects in which some objects contain others; one object may represent.
Software Design and Documentation Individual Presentation: Composite Pattern 9/11/03.
Tirgul OOP No.3 Iterators. What is an Iterator? An object that provides a way to access elements of an aggregate object sequentially, without exposing.
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.
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.
© Spiros Mancoridis 27/09/ Software Design Topics in Object-Oriented Design Patterns Material drawn from [Gamma95] and [Coplien95] Revised and augmented.
Computer Science 209 Introduction to Design Patterns: Iterator Composite Decorator.
Copyright © 2002, Systems and Computer Engineering, Carleton University Patterns.ppt * Object-Oriented Software Development Part 11.
Chapter 9: The Iterator Pattern
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Behavioral Pattern: Iterator C h a p t e r 5 – P a g e 159 Software can become difficult to manage when a variety of different traversals of a variety.
Composite Pattern ( ) Pattern Hatching Chpt 1-2 Presentation by Joe Barzilai 1/30/2006.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
COMPOSITE. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract factory.
CS 210 Iterator Pattern October 31 st, Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
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.
Iterator Pattern. Traversing two different collections  When bringing two previously developed objects together, it can be difficult to change an implementation.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
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.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
1 Iterator Pattern (A Behavioral Pattern) Prepared by: Neha Tomar.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Chapter 5 Patterns and GUI Programming -Part 2-. COMPOSITE Pattern Containers and Components Containers collect GUI components Sometimes, want to add.
Composite Pattern Himanshu Gupta Shashank Hegde CSE776 – Design Patterns Fall 2011 Good composition is like a suspension bridge - each line adds strength.
Template Method Pattern Iterator Pattern
Slide design: Dr. Mark L. Hornick
Observer Design Pattern
Composite Design Pattern
Iterator Design Pattern
Composite Pattern SE2811 Software Component Design
Chapter 17 Object-Oriented Data Structures
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Object-Oriented Design
More Design Patterns 1.
Design Patterns - A few examples
More Design Patterns 1.
Design Patterns A Case Study: Designing a Document Editor
Design Patterns in Game Design
Jim Fawcett CSE776 – Design Patterns Summer 2003
Software Development CSE3311
Menu item at a restaurant
The iterator and memento patterns
Design Patterns Difficult to describe abstractly Elements:
13. Composite Pattern SE2811 Software Component Design
Software Design Lecture : 35.
13. Composite Pattern SE2811 Software Component Design
Composite Design Pattern By Aravind Reddy Patlola.
Software Design Lecture : 39.
Software Design Lecture : 36.
Iterator Design Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014
Presentation transcript:

Iterator and Composite Design Patterns Tuc Goodwin

Agenda Scenario Iterator Pattern Iterator Participants Composite Pattern Composite Pattern Participants

The Book we are Using Head First Design Patterns (ISBN: 0596007124)

Why use an Iterator Pattern? The Iterator pattern allows you to move through a list or collection of data using a standard interface without having to know the details of the internal representation of the data.

Iterator Pattern definition Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation

Iterator Participants The classes and/or objects participating in this pattern are: Iterator  (AbstractIterator) defines an interface for accessing and traversing elements. ConcreteIterator  (Iterator) implements the Iterator interface. keeps track of the current position in the traversal of the aggregate. Aggregate  (AbstractCollection) defines an interface for creating an Iterator object ConcreteAggregate  (Collection) implements the Iterator creation interface to return an instance of the proper ConcreteIterator

Lou’s Diner & Mel’s Diner Lou implemented his menus as an ArrayList Mel implemented his menus as an Array We need to combine the two and display all of the menu items. Do we really want to implement this loop twice? Once for an ArrayList and once for an Array?

DEMO BEFORE PATTERNS / Interfaces

Here’s where we are going…

Demo II After Patterns / Interfaces

Composite Design definition Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Composite Participants The classes and/or objects participating in this pattern are: Component   (DrawingElement) declares the interface for objects in the composition. implements default behavior for the interface common to all classes, as appropriate. declares an interface for accessing and managing its child components. (optional) defines an interface for accessing a component's parent in the recursive structure, and implements it if that's appropriate. Leaf   (PrimitiveElement) represents leaf objects in the composition. A leaf has no children. defines behavior for primitive objects in the composition. Composite   (CompositeElement) defines behavior for components having children. stores child components. implements child-related operations in the Component interface. Client  (CompositeApp) manipulates objects in the composition through the Component interface.

Questions? 9/17/2018

Next Time .NET Development ------------------------------------ January 10 Beginning ASP.NET: DataGrids and Gridviews February 14 Beginning ASP.NET – Part 3 March 14 Beginning ASP.NET – Part 4 April 11 LINQ Patterns ------------------------------------ January 10 State Pattern February 14 Proxy Pattern March 14 Compound Patterns April 11 Better Living with Patterns