Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

Slides:



Advertisements
Similar presentations
Parametric Aspects. A way to design-pattern implementation (...and others)? Jordi Alvarez Open University of Catalonia Barcelona - Spain
Advertisements

Creational Design Patterns. Creational DP: Abstracts the instantiation process Helps make a system independent of how objects are created, composed, represented.
Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Creational Patterns - Page L4-1 PS95&96-MEF-L11-1 Dr. M.E. Fayad Creationa l Paradigm.
CSE3308/CSC Software Engineering: Analysis and DesignLecture 5B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/CSC3080/DMS/2000/12.
Plab – Tirgul 12 Design Patterns
CSE Software Engineering: Analysis and Design, 2005Lecture 8A.1 Software Engineering: Analysis and Design - CSE3308 Design and Analysis Patterns.
Prototype Design Pattern A Creational design pattern.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
Design Patterns A brief introduction to what they are, why they are useful, and some examples of those that are commonly used.
5/08 What is a Design Pattern „Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the.
Prototype Pattern Creational Pattern Specify the kinds of objects to create using a prototypical instance, and create new objects by copy this prototype.
Nov, 1, Design Patterns PROBLEM CONTEXT SOLUTION A design pattern documents a proven solution to a recurring problem in a specific context and its.
CSE Software Engineering: Analysis and Design, 2002Lecture 7B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/DMS/2002/15.
1 CS 501 Spring 2008 CS 501: Software Engineering Lectures 17 & 18 Object Oriented Design 3 & 4.
OOMPA Lecture 10 Design Patterns Singleton Factory Method
Oct, 16, Design Patterns PROBLEM CONTEXT SOLUTION A design pattern documents a proven solution to a recurring problem in a specific context and.
1 Creational Patterns CS : Software Design Winter /T8.
Design Patterns Examples in C++ Moshe Fresko Bar-Ilan University Object Oriented Programming
Creational Patterns: The Abstract Factory CSE 335 Spring 2008 E. Kraemer.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Abstract Factory Pattern.
Pattern Abstract Factory
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns II.
02 - Creational Design Patterns Moshe Fresko Bar-Ilan University תשס"ח 2008.
UML - Patterns 1 Design Patterns. UML - Patterns 2 Becoming Good OO Developers Developing good OO Software is hard Takes a lot of time to take advantage.
Software Components Creational Patterns.
Abstract Factory Abstract Factory using Factory Method.
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.
CDP-1 9. Creational Pattern. CDP-2 Creational Patterns Abstracts instantiation process Makes system independent of how its objects are –created –composed.
Шаблоны проектирования ООП. Принципы ООП Инкапсуляция Наследование Полиморфизм Абстракция данных.
DESIGN PATTERNS Sanjeeb Kumar Nanda 30-Aug What is a pattern? Pattern is a recurring solution to a standard problem Each Pattern describes a problem.
Prototype pattern Participants Prototype (Graphic) – declared an interface for cloning itself ConcretePrototype (EditBox, Slider) – implements an operation.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
ANU COMP2110 Software Design in 2004 Lecture 17Slide 1 COMP2110 in 2004 Software Design Lecture 17: Software design patterns (4) 1The Abstract Factory.
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Advanced Object-oriented Design Patterns Creational Design Patterns.
CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002.
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
 Creational design patterns abstract the instantiation process.  make a system independent of how its objects are created, composed, and represented.
The Abstract Factory Pattern (Creational) ©SoftMoore ConsultingSlide 1.
S.Ducasse Stéphane Ducasse 1 Abstract Factory.
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.
SOFTWARE DESIGN Design Patterns 1 6/14/2016Computer Science Department, TUC-N.
Design Pattern.
Abstract Factory Pattern
Design Patterns A brief introduction to what they are, why they are useful, and some examples of those that are commonly used.
Prof. Chen, Kung (Creational) Design Patterns May 12, 2014
Design Pattern Catalogues
Factory Patterns 1.
Creational Design Patterns
JAVA Design Patterns.
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
What is a Design Pattern
Presented by Igor Ivković
Design Patterns - A few examples
Software Engineering Lecture 7 - Design Patterns
Design Patterns Outline
UNIT-III Creational Patterns UNIT-III.
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Design Patterns Difficult to describe abstractly Elements:
Creational Patterns.
Design by Abstraction (Continuation) CS 3331 Spring 2005
Presented by Igor Ivković
Presentation transcript:

Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes

Abstract Factory pattern Motivation MotifWidgetFactory CreateScrollBar() CreateWindow() PMWidgetFactory CreateScrollBar() CreateWindow() PMWindowMotifWindow PMScrollBarMotifScrollBar WidgetFactory (abstract) CreateScrollBar() CreateWindow() Window ScrollBar Client creates

Abstract Factory Motivation

Abstract Factory Structure Provide an interface for creating families of related or dependent objects without specifying their concrete class

Abstract Factory pattern Structure ConcreteFactory1 CreateProductA() CreateProductB() ConcreteFactory2 CreateProductA() CreateProductB() ProductA2 ProductA1 ProductB2 ProductB1 AbstractFactory CreateProductA() CreateProductB() AbstractProductA AbstractProductB Client creates

Abstract Factory pattern Applicability Use the Abstract Factory pattern when – a system should be independent of how its products are created, composed and represented – a system should be configured with one of multiple families of products – a family of related product objects is designated to be used together, and you need to enforce this constraint – you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations

Abstract Factory pattern Participants AbstractFactory (WidgetFactory) – declares an interface for operations that create abstract product objects ConcreteFactory (MotifWidgetFactory,…) – implements the operations to create concrete product objects AbstractProduct (Window, ScrollBar) – declared an interface for a type of product object ConcreteProduct (MotifWindow, MotifScrollBar) – defines a product object to be created by the corresponding concrete factory – implements the AbstractProduct interface Client – uses only interfaces declared by AbstractFactory and AbstractProduct classes

Abstract Factory - consequences Isolates concrete classes Makes exchanging product families easy – the class of concrete factory appears only once in the application - that is, where it’s instantiated Promotes consistency among products – enforces, that products from one family are used together Supporting new kinds of products is difficult – AbstractFactory interface fixes the set of products that can be created – involves changing AbstractFactory and all its subclasses interfaces

Abstract Factory - implementation Factories as singletons Creating the products – use Factory Method pattern declare FactoryMethod for each kind of product in AbstractFactory override FactoryMethod in ConcreteFactory – use Prototype pattern for ConcreteFactory if many product families are possible initialize the concrete factory with a prototypical instance of each product in the family concrete factory will create a new product by cloning the prototype no need for a new concrete factory class for each new family Defining extensible factories – Via parameterization -- I.e., object = factory.make ( typeA ) ; – Via mixing concrete and abstract factory hierarchies.