Feb 200692.3913 Ron McFadyen1 Iterator Pattern Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate interface.

Slides:



Advertisements
Similar presentations
Winter 2007ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
Advertisements

Winter 2007ACS-3913 Ron McFadyen1 Also known as publish/subscribe The essence of this pattern is that one or more objects (called observers or listeners)
Jan 29, Ron McFadyen1 UML Class Diagram Examples Based on well-known patterns Exhibit ways of providing dynamic structures and behaviour.
Oct Ron McFadyen1 Collaborations Collaboration : an arrangement of classes, links, roles in a context to implement some behaviour. Name of.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Feb 18, R McFadyen > An approach promoted by Martin Fowler in Analysis Patterns.
Oct 22, Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
March Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.
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.
Fall 2009ACS-3913 Ron McFadyen1 Decorator Pattern The Decorator pattern allows us to enclose an object inside another object. The enclosing object is called.
Feb Ron McFadyen1 Iterator Pattern Recall Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate.
Bag implementation Add(T item) – Enlarge bag if necessary; allocate larger array Remove(T item) – Reduce bag if necessary; allocate smaller array Iterator.
Head-First Design Patterns. Similar to a ReminderEntry.
Spring 2010ACS-3913 Ron McFadyen1 Weather Station Page 39+ In this application, weather station devices supply data to a weather data object. As the data.
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Feb Ron McFadyen1 Factory Method Iterator Example : Java collection classes represent an example of the Factory Method design pattern. The.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Sept 2004Ron McFadyen Decorator Pattern The decorator pattern allows us to enclose an object inside another object. The enclosing object is called.
Fall 2007ACS Ron McFadyen1 Composite Pattern (see pages ) A composite is a group of objects in which some objects contain others; one object.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 7 Repetition.
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
Feb Ron McFadyen1 Adapter An adapter converts the interface of a class into another interface the client expects. An adapter lets classes work.
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
March Ron McFadyen1 Using Rational Rose to create a database.
Design Patterns. CS351 - Software Engineering (AY2007)Slide 2 Behavioral patterns Suppose we have an aggregate data structure and we wish to access the.
Spring 2010ACS-3913 Ron McFadyen1 Command The command pattern encapsulates a request or unit of work into an object. An invoker will ask a concrete command.
ACS-3913Fall 2009 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Oct Ron McFadyen1 Collaborations Collaboration : an arrangement of classes, links, roles in a context to implement some behaviour. Useful for.
Winter 2015ACS Ron McFadyen1 Composite Pattern A composite is a group of objects in which some objects contain others; one object may represent.
Winter 2007ACS-3913 Ron McFadyen1 Observer Pattern Problem: There are many objects (observers / subscribers) needing to know of the state changes, or events,
Winter 2011ACS Ron McFadyen1 Façade A façade simplifies access to a related set of objects by providing one object that all objects outside the.
March Ron McFadyen1 Singleton pattern Singleton is designed to restrict instantiation of a class to one (or a few) objects. Useful when exactly.
1 Object Oriented Design & Patterns Part 1. 2 Design Patterns Derived from architectural patterns: –rules for design of buildings –describe common problems,
Winter 2011ACS-3913 Ron McFadyen1 Decorator Sometimes we need a way to add responsibilities to an object dynamically and transparently. The Decorator pattern.
Spring 2010ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
Feb 4, Ron McFadyen1 founded on principles of good OO design idea was first put forth by Christopher Alexander (1977) in their work concerning.
Abstract Factory Design Pattern making abstract things.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Copyright © 2002, Systems and Computer Engineering, Carleton University Patterns.ppt * Object-Oriented Software Development Part 11.
Chapter 9: The Iterator Pattern
程式語言結構 Final Project. Goal The student can gain the knowledge of the object operation for the Java programming language. –Class –Interface.
Jan Ron McFadyen1 Decorator Sometimes we need a way to add responsibilities to an object dynamically and transparently. The Decorator pattern.
程式語言結構 Final Project 老師: Gwan-Hwan Hwang. Goal The students can gain the knowledge of the object operation for the Java programming language. –Class –Interface.
Sept Ron McFadyen1 Today Sept 16: Chapters 1, 2, 3 Introductory material Next Tuesday Sept 21: Rational Rose and Use Cases Chapter 6 - Use.
November Ron McFadyen1 Composite Pattern A composite is a group of objects in which some objects contain others; one object may represent groups,
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.
Chapter 7: The Adapter Pattern. Object Oriented Adapters Suppose that you have existing software. You have outsourced some of your work and there is a.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
CS 210 Iterator Pattern October 31 st, Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another.
What is Iterator Category: Behavioral Generic Way to Traverse Collection Not Related to Collection Implementation Details Not Related to the direction/fashion.
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.
1 Iterator Pattern (A Behavioral Pattern) Prepared by: Neha Tomar.
UML - Unified Modeling Language
Iterator Design Pattern
Iterator and Composite Design Patterns
Adapter, Fascade, and More
Chapter 5 Structures.
Iterator.
Chapter 9 Behavioral Design Patterns
Menu item at a restaurant
The iterator and memento patterns
Lists Chapter 8.
Software Design Lecture : 39.
Decorator Pattern The decorator pattern allows us to enclose an object inside another object. The enclosing object is called a decorator. The other object.
defines a higher-level interface that makes a subsystem easier to use
4 Step Simple Diagram Sample text Sample text Sample text Sample text
4 Steps Thumbs Up Puzzle Diagram
Iterator Design Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014
Presentation transcript:

Feb Ron McFadyen1 Iterator Pattern Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate interface gives us a common way to create an iterator. The iterator interface gives us a common way to access components of the aggregate > Aggregate createIterator() next() hasNext() remove() ConcreteAggregate Client ConcreteIterator() > Iterator next() hasNext() remove() createIterator()

Feb Ron McFadyen2 Text Example UML class diagram Each menu class has responsibility to create the necessary iterator. Note that the iterator pattern is an example of a Factory (i.e. objects are created). > Menu createIterator() next() hasNext() remove() PancakeHouseMenu Waitress DinerMenuIterator() > Iterator next() hasNext() remove() createIterator() DinerMenu createIterator() PancakeHouseIterator() next() hasNext() remove()

Feb Ron McFadyen3 Sample Behaviour :DinerMenu :Waitress :DinerMenuIterator createIterator() new() hasNext() next() Loop [hasNext true] hasNext()