Design Patterns Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson,Ralph Johnson and John Vlissides (The Gang of.

Slides:



Advertisements
Similar presentations
Lecture 9 Design Patterns CSCI – 3350 Software Engineering II Fall 2014 Bill Pine.
Advertisements

18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
SE2811 Week 7, Class 2 The Gang of Four and more … Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Design Patterns Yes, they are important Robert Cotton April 23, 2009.
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
Fundamentals of Software Development 1Slide 1 Gang of Four The beginnings… The original “patterns” idea was from architecture – there are repeatable patterns.
Design Patterns In OPM Presented by: Galia Shlezinger Instructors: Prop. Dov Dori, Dr. Iris Berger.
IEG3080 Tutorial 7 Prepared by Ryan.
Design Patterns CS is not simply about programming
Design Patterns Daniel McClain. Background What are they?  Way of recording solutions to recurring design problems History  “A Pattern Language: Towns,
Visitor Pattern Jeff Schott CS590L Spring What is the Purpose of the Visitor Pattern ? n Represent an operation to be performed on the elements.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Adapters Presented By Zachary Dea. Definition A pattern found in class diagrams in which you are able to reuse an ‘adaptee’ class by providing a class,
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
1 Computer Science 340 Software Design & Testing © Ken Rodham 2003 The “Visitor” Design Pattern Source: "Design Patterns: Elements of Reusable Software"
Builder A Creational Design Pattern A Presentation by Alex Bluhm And.
Object-Oriented Design Patterns CSC 335: Object-Oriented Programming and Design.
Design Patterns Introduction. What is a Design Pattern?  A technique to repeat designer success.  Borrowed from Civil and Electrical Engineering domains.
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
Design Patterns Trends and Case Study John Hurst June 2005.
樣式導向設計 (Pattern-Oriented Design) 課程簡介 Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
CSSE 374: Introduction to Gang of Four Design Patterns
Advanced topics in software engineering CSC532 Term Paper Design Patterns Harpreet Singh Submitted By:-
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
CSE 403, Spring 2008, Alverson Software Design “There are two ways of constructing a software design: one way is to make it so simple that there are obviously.
....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.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
1 Design Patterns Object-Oriented Design. 2 Design Patterns 4Reuse of design knowledge and experience 4Common in many engineering disciplines 4Avoids.
Creational Patterns
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
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.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Patterns Composite Pattern. Patterns All designers use patterns. Patterns in solutions come from patterns in problems. "A pattern is a solution to a problem.
The Visitor Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Game Programming Patterns From the book by Robert Nystrom
The Visitor Design Pattern. What’s It All About? Allows for new operations to be defined and used on elements of an object structure with out changing.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
樣式導向設計 (Pattern-Oriented Design) 課程簡介
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Design Patterns Introduction
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Presented by Igor Ivković
Design Patterns in Game Design
08/15/09 Design Patterns James Brucker.
Informatics 122 Software Design II
CSE 403 Software Design.
DESIGN PATTERNS : Introduction
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Informatics 122 Software Design II
Composite Design Pattern By Aravind Reddy Patlola.
Presentation transcript:

Design Patterns Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson,Ralph Johnson and John Vlissides (The Gang of Four).The Gang of Four

Abstract Factory

Adapter

Bridge

Command

Composite

Façade

Observer

Proxy

Strategy

Visitor Pattern

Visitor Intent Given an existing structure such as a tree or graph whose nodes are objects from different classes Add new behavior to the system Without adding new operations to the classes By encapsulating the new behavior in visitor objects Which traverse the structure performing tasks when they visit the nodes

Parse Tree Visitors A source programming file is parsed A parse tree is constructed Its nodes represents represent productions in the grammar (~100 different classes) We need to add compiler functionality: –Checking, code generation, optimization Without modifying the node classes

Sample Parse Tree

The Solution Add operations to the parse tree nodes To support a depth-first traversal of the tree By an abstract Visitor object. The Visitor has before and after methods for each kind of node. Class visitor{ void before(expr e){}; void after(expr e){}

Double Dispatch The traversal code calls the Visitor’s before method when the visitor arrives at a node, its after method before it leaves the node. Concrete visitors do specific tasks such as checking and code generation The specific before and after methods called depend on the type of the concrete visitor and the type of the node. (double dispatch)

Visiting a Train -> { }* abstract class Visitor{ public Visitor(){} public void before(Train host){} public void after(Train host){} public void before(Engine host){} public void after(Engine host){} public void before(Car host){} public void after(Car host){} }

A visit method in the Train class public void visit(Visitor v){ v.before(this); if (engine!= null) engine.visit(v); Enumeration enumCars = getCars().elements(); while(enumCars.hasMoreElements()){ Car it = (Car) enumCars.nextElement(); it.visit(v); } v.after(this); }

When to use the Visitor Pattern When an object structure contains many classes of objects with differing interfaces and you want to perform operations on these objects that depend on their concrete classes. You want to encapsulate functionality in a single concrete visitor