Fall 2009ACS-3913 R McFadyen1 GoF Patterns, chapter 26 GoF book presents 23 patterns: Creational – 5 Structural – 7 Behavioural – 11 Larman discusses 7.

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

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.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
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.
Oct R McFadyen1 Recall UML Class Diagram BusRoute BusStopList BusStop BusList BusPersonList Person passengers buses busStops waiting 0..*
Feb R. McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:
Nov R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (section 23.3 has a Simple.
Fall 2009ACS-3913 Ron McFadyen1 Decorator Pattern The Decorator pattern allows us to enclose an object inside another object. The enclosing object is called.
Fall 2009ACS-3913 R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (Simple Factory) Prototype.
March R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (in Larman) Prototype Singleton.
Nov R McFadyen1 Strategy A strategy is a plan, or approach, for achieving an aim, given certain input conditions. Often strategies appear in.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
Nov Ron McFadyen1 Figure The Observer Pattern in a DCD.
Fall 2009ACS Ron McFadyen1 The context maintains an instance of a concrete state subclass State Pattern Each subclass (concrete state) implements.
Fall 2009ACS-3913 Ron McFadyen1 idea was first put forth by Christopher Alexander (1977) in his work on architectural design principles a pattern is a.
Winter 2007ACS-3913 Ron McFadyen1 Classes Represented by a rectangle with possibly 3 compartments Customer Name Address Customer Name Address getName()
March R McFadyen1 Façade. March R McFadyen2 Facade P Main Entry: fa·cade Variant(s): also fa·çade / f&-'säd/ Function: noun.
February Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Fall 2009ACS-3913 R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) More GRASP Patterns.
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Fall 2009ACS-3913 R McFadyen1 Singleton Problem: Exactly one instance of a certain object is required (this object is called a singleton). We must ensure.
Object Oriented Analysis and Design Chapter 1 Applying UML and Patterns -Craig Larman.
Oct Ron McFadyen1 Collaborations Collaboration : an arrangement of classes, links, roles in a context to implement some behaviour. Useful for.
Object-Oriented Software Engineering Practical Software Development using UML and Java Design Patterns Sources: Chapter 6: Using Design Patterns, and Chapter.
NJIT Applying GOF Design Patterns Chapter 26 Applying UML and Patterns Craig Larman Presented By : Naga Venkata Neelam.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
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.
Fall 2009ACS-3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary ( Main Entry: an·thro·po·mor·phism Date: 1753 an interpretation.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
L6 - March 1, 2006copyright Thomas Pole , all rights reserved 1 Lecture 6: Software Packaging: Dynamically Integrable Components and Text Ch.
MVC and MVP. References enter.html enter.html
樣式導向設計 (Pattern-Oriented Design) 課程簡介 Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
CSSE 374: 3½ Gang of Four Design Patterns These slides derived from Steve Chenoweth, Shawn Bohner, Curt Clifton, and others involved in delivering 374.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
BTS430 Systems Analysis and Design using UML Design Patterns.
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
TK2023 Object-Oriented Software Engineering CHAPTER 3 CASE STUDY: POS SYSTEM.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Software Engineering 1 Object-oriented Analysis and Design Chap 24 Iteration 2 More Patterns.
OO Methodology Elaboration Iteration 2 - Design Patterns -
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
The Strategy Design Pattern © Allan C. Milne v
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
OO Methodology Elaboration Iteration 3 – Part 3 - More Design Patterns -
Presentation on GoF Design Patterns Submitted by WWW. ASSIGNMENTPOINT
GoF Patterns (GoF) popo.
Design Patterns Lecture part 2.
Conception OBJET GRASP Patterns
MARKETING PROCESS.
Chapter 8, Design Patterns Bridge
Design Patterns (GoF) contains the creational patterns:
Facade From Main Entry: fa·cade Variant(s): also fa·çade /f&-'säd/ Function: noun Etymology: French façade, from Italian facciata,
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
GoF Design Patterns (Ch. 26)
Object Oriented Design Patterns - Creational Patterns
Graphical User Interfaces in Java Event-driven programming
CS 350 – Software Design Principles and Strategies – Chapter 14
GoF Design Patterns (Ch. 26)
GoF Patterns Ch. 26.
Presentation transcript:

Fall 2009ACS-3913 R McFadyen1 GoF Patterns, chapter 26 GoF book presents 23 patterns: Creational – 5 Structural – 7 Behavioural – 11 Larman discusses 7 Many texts cover the GoF patterns, examples: Java design patterns; James Cooper Head First Design Patterns; Freeman & Freeman Design patterns explained; Shalloway & Trott Object-oriented design & patterns; Horstmann …

Fall 2009ACS-3913 R McFadyen2 GoF Patterns, chapter 26 Some web sites Data & Object Factory Allen Holub Showing pattern collaborations Models.pdf Models.pdf

Fall 2009ACS-3913 R McFadyen3 A strategy is a plan, or approach, for achieving an aim, given certain input conditions. Often strategies appear in groups or families When multiple strategies are available, the logic to select one may be complicated. We can clean up such code with Strategy Strategy

Fall 2009ACS-3913 R McFadyen4 Create an interface to define the strategic operation Implement the interface with classes that represent each strategy These classes contain the strategy code We need to determine which strategy to apply The choice of which strategy to apply could be handled by a strategy factory Using strategy

Fall 2009ACS-3913 R McFadyen5 In the text, they want to be able to use varying pricing strategies for sales. Strategies such as Give a discount if sales are over … Always give a discount of … Give frequent customers a discount … The strategy in effect will vary … This is a point of variation in the system … and we want the system to be flexible Having several pricing strategies

Fall 2009ACS-3913 R McFadyen6 Textbook example > ISalePricingStrategy getTotal():Money PercentDiscount PicingStrategy percentage: float getTotal():Money AbsoluteDiscount OverThreshold PicingStrategy discount: Money threshold: Money getTotal():Money … Sale

Fall 2009ACS-3913 R McFadyen7 A strategy collaboration s: Sale:salesLineItem[i]:PercentDiscount PricingStrategy getTotal() * : getSubTotal() getTotal(s)

Fall 2009ACS-3913 R McFadyen8 How is the strategy object created? Usually, at most one object of each class is required … Use a factory

Fall 2009ACS-3913 R McFadyen9 Strategy singleton : Sale ps:PercentDiscount PricingStrategy new() getSalePricingStrategy() new() > :PricingStrategyFactory In NextGenPOS, its possible to use a different strategy at any time … need code to replace the current strategy