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.

Slides:



Advertisements
Similar presentations
T O K ILL A S INGLETON F ACTORY M ETHOD P ATTERN Josh Mason 6/18/09.
Advertisements

Chapter 7 Testing Class Hierarchies. SWE 415 Chapter 7 2 Reading Assignment  John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Generator Design Patterns: The Factory Patterns.
Design Patterns A General reusable solution to a commonly occurring problem in software design. Creational: Deal with object creation mechanisms – Example:
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
Prototype Design Pattern A Creational design pattern.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
Creational Patterns: The Abstract Factory CSE 335 Spring 2008 E. Kraemer.
+ Informatics 122 Software Design II Lecture 8 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Design Patterns.
Design Patterns. Now you are ready for Design Patterns Design patterns are recurring solutions to software design problems you find again and again in.
Creational Patterns (1) CS350, SE310, Fall, 2010.
Abstract Factory Design Pattern making abstract things.
Factory Method A Creational Design Pattern. Factory Method Key Features  Defines an interface for creating objects without needing to know each object’s.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
12/6/20041 The Factory Method Pattern Presenters 王世賀 F 陳祐毓 F 張峻銘 F 吳佩達 F 林俊成 F 鄭榮智 F 許書豪 F
The Factory Patterns SE-2811 Dr. Mark L. Hornick 1.
Design Patterns Façade, Singleton, and Factory Methods Team Good Vibrations (1)
Mohammed Al-Dhelaan CSci 253 Object Oriented Design Instructor: Brad Taylor 06/02/2009 Factory Method Pattern.
Creational Patterns CSE Creational Patterns Class creational pattern ◦ uses inheritance to vary the class that is instantiated Object creational.
Factory Method Chris Colasuonno Also known as “Virtual Constructor”
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.
CDP-1 9. Creational Pattern. CDP-2 Creational Patterns Abstracts instantiation process Makes system independent of how its objects are –created –composed.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
Factory Method Explained. Intent  Define an interface for creating an object, but let subclasses decide which class to instantiate.  Factory Method.
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.
Creational Pattern: Factory Method At times, a framework is needed to standardize the behavior of objects that are used in a range of applications, while.
CS 590L – Distributed Component Architecture 02/20/2003Uttara Paingankar1 Design Patterns: Factory Method The factory method defines an interface for creating.
Builder An Object Creational Pattern Tim Rice CSPP51023 March 2, 2010.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
The Factory Method Pattern (Creational) ©SoftMoore ConsultingSlide 1.
The Factory Pattern Sanjay Yadav (ISE ).
Advanced Object-oriented Design Patterns Creational Design Patterns.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
Abstract Factory Pattern Jiaxin Wang CSPP Winter 2010.
1 Design Patterns prepared for COMP314, Bernhard Pfahringer see links on the web page as well!
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
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
Advanced Programming in Java
Advanced Programming in Java
Unit II-Chapter No. : 5- design Patterns
Factory Method Pattern
Design Patterns C++ Java C#.
Low Budget Productions, LLC
Factory Patterns 1.
Interface, Subclass, and Abstract Class Review
Inheritance and Polymorphism
Design Patterns C++ Java C#.
Software Design and Architecture
Factory Method Pattern
Software Engineering Lecture 7 - Design Patterns
Object Oriented Design Patterns - Creational Patterns
CSE 432 Presentation GoF: Factory Method PH: “To Kill a Singleton”
Factory Pattern.
Abstract Classes Page
Advanced Programming in Java
Recitation 9 October 28, 2011.
CS 350 – Software Design Singleton – Chapter 21
Lesson 5: More on Creational Patterns
Design by Abstraction (Continuation) CS 3331 Spring 2005
Presentation transcript:

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 will be creating or explicitly calling the object’s constructor. As a result, we get less code repetition and a higher degree of abstraction This can be useful when a class cant anticipate the type of object it must create.

Definition/Description A factory method is a creational pattern Its purpose is to define an interface for creating objects which allows a class to defer instantiation to a subclass Factory method is another, more abstract and elegant way of creating object with the same base class without using their constructor “Multi-SubClass Constructor”

Terminology Product - usually an abstract type of object that a factory method will create Concrete Product – a concrete instance of Product Creator - abstract type/interface which returns an object of type Product. Concrete Creator – overrides the factory method in Creator

UML

Advantages Reduce code verbosity Have clear distinguishable name for the Factory Method unlike constructors Not required to create a new object when called, this adds to flexibility

Disadvantages Code can become more confusing

REFERENCES Design Patterns by Gang of Four Wikipedia Stack Overflow