Design by Abstraction (Continuation) CS 3331 Spring 2005

Slides:



Advertisements
Similar presentations
Creational Design Patterns. Creational DP: Abstracts the instantiation process Helps make a system independent of how objects are created, composed, represented.
Advertisements

Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
Plab – Tirgul 12 Design Patterns
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
Patterns Lecture 2. Singleton Ensure a class only has one instance, and provide a global point of access to it.
Creational Patterns: The Abstract Factory CSE 335 Spring 2008 E. Kraemer.
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.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Design Patterns.
1 GoF Template Method (pp ) GoF Strategy (pp ) PH Single User Protection (pp ) Presentation by Julie Betlach 6/08/2009.
Case Studies on Design Patterns Design Refinements Examples.
12/6/20041 The Factory Method Pattern Presenters 王世賀 F 陳祐毓 F 張峻銘 F 吳佩達 F 林俊成 F 鄭榮智 F 許書豪 F
Strategy Design Patterns CS 590L - Sushil Puradkar.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
The Factory Method Design Pattern Motivation: Class / Type separation – Abstract class serves as type definition and concrete class provides implementation.
Abstract Factory and Factory Method CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Design Pattern Dr. Zhen Jiang West Chester University url:
Define an interface for creating an object, but let subclasses decide which class to instantiate.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
CSC 480 Software Engineering Design With Patterns.
CS 590L – Distributed Component Architecture 02/20/2003Uttara Paingankar1 Design Patterns: Factory Method The factory method defines an interface for creating.
Template Methods Ordering What We Do. Example - Solitaire Initialization of many solitaire games follow this pattern: Shuffle the cards Layout the game.
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
Design Patterns: Design by Abstraction
CS 210 Final Review November 28, CS 210 Adapter Pattern.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
The Template Method Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Advanced Object-oriented Design Patterns Creational Design Patterns.
CSC 480 Software Engineering Design With Patterns.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
CS 5150 Software Engineering Lecture 16 Program Design 3.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
STRATEGY PATTERN By Michelle Johnson. BACKGROUND Behavioral Pattern Allow you to define a family of algorithms, encapsulate each one, and make them interchangeable.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Abstract Factory Pattern Jiaxin Wang CSPP Winter 2010.
Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Factory Method. Intent/Purpose Factory Method is used to deal with a problem of creating objects without specifying the EXACT class of object that we.
Factory Method Pattern. Admin SCPI Patner Day Feb. 21 Lunch count Presentation (4-8 min.) Practice on Feb. 16. Morning availablity on Feb21 Brief overview.
Design Patterns: MORE Examples
Strategy: A Behavioral Design Pattern
Abstract Factory Pattern
Unit II-Chapter No. : 5- design Patterns
Factory Method Pattern
Strategy Design Pattern
Factory Patterns 1.
Software Design and Architecture
Software Design and Architecture
Design Patterns with C# (and Food!)
Factory Method Pattern
object oriented Principles of software design
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Introduction to Behavioral Patterns (3)
State Design Pattern 1.
Object Oriented Design Patterns - Creational Patterns
Object Oriented Design Patterns - Behavioral Patterns
CSC 480 Software Engineering
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Strategy and Template Method Patterns, Single User Protection
Strategy Design Pattern
Creational Patterns.
CSC 480 Software Engineering
Design Patterns (Gamma, Helm, Johnson, Vlissides)
CSC 480 Software Engineering
Presentation transcript:

Design by Abstraction (Continuation) CS 3331 Spring 2005

Outline Design Patterns Template method Strategy pattern Factory pattern CS 3331

Template Methods Intent Participants To define the skeleton of an algorithm by deferring some steps to subclasses To allow subclasses to redefine certain steps Participants Generic Class defines abstract hook methods and implements template methods Concrete Class implements hook methods GenericClass templateMethod() hookMethod1() hookMethod2() ConcreteClass … CS 3331

Template Methods (Cont.) Terminology Template methods: methods containing hook methods Hook methods: placeholders for the behaviour to be implemented differently by subclasses Frozen spots: fixed behaviours of generic classes represented by template methods Hot spots: changeable behaviours of generic classes represented by hook methods CS 3331

Example Complex numbers Rectangular Polar imaginary (x, y) (r, a) r y real imaginary Polar (r, a) r a CS 3331

Example Template Methods Hook Methods ComplexNumber add() mul() realPart() imaginaryPart() magnitude() angle() RectangularComplex PolarComplex Template Methods Hook Methods CS 3331

Strategy Design Pattern Intent To define a family of algorithms, encapsulate each one, and make them interchangeable Participants Context maintains references to Strategy objects Strategy declares a common interface to all supported algorithms ConcreteStrategy implements the algorithm using the Strategy interface Context contextMethod() Strategy ConcreteStrategyA algorithm() alogorithm() ConcreteStrategyB CS 3331

Factory Design Pattern Intent To decouple object creation from its use and to support different way of creating objects To define an interface for creating objects but let subclasses decide which class to instantiate and how Participants Abstract Factory defines a factory method that returns a Product object ConcreteFactory overrides the factory method to return an instance of ConcreteProduct Product defines an interface of the objects that the factory will create ConcreteProduct implements the product interface Product AbstractFactory makeProduct() creates ConcreteFactory makeProduct() ConcreteProuct CS 3331

Example Complex numbers Complex ComplexFactory makeComplext() PolarFactory makeComplex() PolarComplex creates RectangularFactory makeComplex() RectangularComplex creates CS 3331