CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.

Slides:



Advertisements
Similar presentations
Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Advertisements

4. Object-Oriented Programming Procedural programming Structs and objects Object-oriented programming Concepts and terminology Related keywords.
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
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.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Design Patterns CS is not simply about programming
Visitor Matt G. Ellis. Intent Metsker: Let developers define a new operation for a hierarchy without changing the hierarchy classes. GoF: Represent an.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
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.
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
CSE 331 Software Design & Implementation Hal Perkins Winter 2013 Design Patterns Part 3 (Slides by Mike Ernst and David Notkin) 1.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
Composite Design Pattern. Motivation – Dynamic Structure.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
CSE 332: Design Patterns (Part I) Introduction to Design Patterns Design patterns were mentioned several times so far –And the Singleton Pattern was discussed.
Creational Patterns (1) CS350, SE310, Fall, 2010.
© 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.
Go4 Visitor Pattern Presented By: Matt Wilson. Introduction 2  This presentation originated out of casual talk between former WMS “C++ Book Club” (defunct.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Lexi case study (Part 2) Presentation by Matt Deckard.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
GoF: Document Editor Example Rebecca Miller-Webster.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
....and other creepy things from John Vlissides The Visitor Pattern EXISTS! And its INTENT is to represent an operation to be performed on the elements.
ECE450S – Software Engineering II
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
What to know for the exam. Smalltalk will be used for questions, but there will not be questions about the grammar. Questions might ask – how particular.
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 and Related Patterns Kirk Scott. The pitohui, a poisonous bird of New Guinea.
CS212: Object Oriented Analysis and Design Lecture 37: Design Pattern.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
The Visitor Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
CS 210 Iterator Pattern October 31 st, Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another.
Interface Patterns. Adapter Provides the interface a client expects, using the services of a class with a different interface Note Avoid using object.
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.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
CSE 332: Design Patterns (Part II) Last Time: Part I, Familiar Design Patterns We’ve looked at patterns related to course material –Singleton: share a.
Behavioural Patterns GoF pg Iterator GoF pg. 257 – 271 Memento GoF pg By: Dan Sibbernsen.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
COMPOSITE PATTERN NOTES. The Composite pattern l Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Introduction to Design Patterns
Chapter 10 Design Patterns.
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
Iterator and Composite Design Patterns
Object-Oriented Design
CS 4240 Principles of SW Design
Design Patterns A Case Study: Designing a Document Editor
Design Patterns in Game Design
Jim Fawcett CSE776 – Design Patterns Summer 2003
Object Oriented Design Patterns - Behavioral Patterns
The iterator and memento patterns
Design Patterns Difficult to describe abstractly Elements:
13. Composite Pattern SE2811 Software Component Design
Composite Design Pattern By Aravind Reddy Patlola.
Software Design Lecture : 39.
16. Visitors SE2811 Software Component Design
16. Visitors SE2811 Software Component Design
Software Design Lecture : 36.
Key Takeaway Points Applying situation-specific patterns during the design process. Begin with the design problems encountered, select the right patterns,
Iterator Design Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014
Presentation transcript:

CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III

Recap of Lecture 38 Abstract Factory Singleton Adapter

Outline of Lecture 39 Composite Pattern Iterator Pattern Visitor Pattern

Composite: Intent Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly 1-to-many "has a" up the "is a" hierarchy

Composite: Problem Application needs to manipulate a hierarchical collection "primitive" and "composite" objects Primitive object is handled one way Composite object is handled differently Composites that contain components, each of which could be a composite

Composite: Structure Example Menus that contain menu items, each of which could be a menu. Row-column GUI layout managers that contain widgets, each of which could be a row-column GUI layout manager. Directories that contain files, each of which could be a directory. Containers that contain Elements, each of which could be a Container. …

Composite: Example (2 + 3) + (4 * 6)

Composite: Check list Problem is about representing "whole-part“ Divide your domain concepts into container classes, and containee classes All container and containee classes declare an "is a" relationship to the interface All container classes declare a one-to-many "has a" relationship to the interface. Child management methods

Mar-15 Catalogue of Design Patterns (GoF) Software Engineering

Iterator: Intent Access the elements of an aggregate object sequentially Promote to "full object status" the traversal of a collection. Polymorphic traversal

Iterator: Problem Need to "abstract" the traversal of wildly different data structures Algorithms can be defined that are capable of interfacing with each transparently.

Iterator: Discussion An aggregate object such as a list should give you a way to access its elements without exposing its internal structure Traverse the list in different ways, depending on what you need to accomplish You might also need to have more than one traversal pending on the same list

Iterator: Structure

Iterator: Example

Iterator: Check List Add a create_iterator() method to the "collection" class, and grant the "iterator" class privileged access. Design an "iterator" class that can encapsulate traversal of the "collection" class. Clients ask the collection object to create an iterator object. Clients use the first(), is_done(), next(), and current_item() protocol to access the elements of the collection class.

Visitor: Intent Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. The classic technique for recovering lost type information. Double dispatch

Visitor: Problem Visitor pattern allows to separate the data structures and the algorithms to be applied on the data. Both data structure objects and algorithm objects can evolve separately. Data structure (element) objects have an "accept" method which take in a visitor (algorithmic) object. Algorithmic objects have a "visit" method which take in a data structure object.

Visitor: Discussion Encourages designing lightweight element classes Visitor implements "double dispatch".

Visitor: Structure

Visitor: Example

Visitor: Check list Confirm that the current hierarchy Create a Visitor base class with a visit(ElementXxx) method for each Element derived type. Add an accept(Visitor) method to the Element hierarchy Create a Visitor derived class for each "operation" to be performed on Element objects. The client creates Visitor objects and passes each to Element objects by calling accept.

Thank you Next Lecture: Design Pattern