S.Ducasse Stéphane Ducasse 1 Abstract Factory.

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 (2) CS350/SE310 Fall, Lower the Cost of Maintenance Economic Goal Coupling-Cohesion, Open-Close, Information-Hiding, Dependency.
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
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.
Prototype Pattern Intent:
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
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.
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.
S.Ducasse Stéphane Ducasse 1 Selected Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns II.
Creational Patterns (1) CS350, SE310, Fall, 2010.
02 - Creational Design Patterns Moshe Fresko Bar-Ilan University תשס"ח 2008.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Software Components Creational Patterns.
Abstract Factory Abstract Factory using Factory Method.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Creational Patterns CSE Creational Patterns Class creational pattern ◦ uses inheritance to vary the class that is instantiated Object creational.
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.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
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.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns I.
Advanced Object-oriented Design Patterns Creational Design Patterns.
CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002.
S.Ducasse Stéphane Ducasse 1 Decorator.
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.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
The Abstract Factory Pattern (Creational) ©SoftMoore ConsultingSlide 1.
S.Ducasse Stéphane Ducasse 1 Adapter.
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.
SOFTWARE DESIGN Design Patterns 1 6/14/2016Computer Science Department, TUC-N.
07 - Creational PatternsCSC4071 Creational Patterns Patterns used to abstract the process of instantiating objects. –class-scoped patterns uses inheritance.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
1 DesignPattern-3 Creational Patterns Suntae Kim Kangwon National University
Design Pattern.
Abstract Factory Pattern
Strategy Design Pattern
Design Pattern Catalogues
Factory Patterns 1.
Software Design and Architecture
Design Patterns with C# (and Food!)
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Presented by Igor Ivković
Design Patterns - A few examples
Software Engineering Lecture 7 - Design Patterns
Abstract Factory Pattern
Object Oriented Design Patterns - Creational Patterns
UNIT-III Creational Patterns UNIT-III.
Prototype Pattern 1.
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Creational Patterns.
Presented by Igor Ivković
Presentation transcript:

S.Ducasse Stéphane Ducasse 1 Abstract Factory

S.Ducasse License: CC-Attribution-ShareAlike

S.Ducasse 3 Abstract Factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes Also known as: Kit

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

S.Ducasse 5 Abstract Factory Motivation You have an application with different looks and feels. How to avoid to hardcode all the specific widget classes into the code so that you can change from Motifs to MacOsX?

S.Ducasse 6 Abstract Factory Motivation Abstract factory introduce an interface for creating each basic kind of widget

S.Ducasse 7 Abstract Factory Applicability 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 designed 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

S.Ducasse 8 Abstract Factory Structure

S.Ducasse 9 Abstract Factory Participants AbstractFactory (WidgetFactory) declares an interface for operations that create abstract product objects ConcreteFactory (MotifWidgetFactory, PMWidgetFactory) implements the operations to create concrete product objects

S.Ducasse 10 Abstract Factory Participants AbstractProduct (Window, ScrollBar) 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

S.Ducasse 11 Implementation: Specifying the Factory MazeGame class>>createMazeFactory ^ (MazeFactory new addPart: Wall named: #wall; addPart: Room named: #room; addPart: Door named: #door; yourself) EnchantedMazeGame class>>createMazeFactory ^ (MazeFactory new addPart: Wall named: #wall; addPart: EnchantedRoom named: #room; addPart: DoorNeedingSpell named: #door; yourself)

S.Ducasse 12 SingleFactory MazeGame class>>createMazeFactory ^ (MazeFactory new addPart: Wall named: #wall; addPart: Room named: #room; addPart: Door named: #door; yourself) MazeGame class>>createEnchantedMazeFactory ^ (MazeFactory new addPart: Wall named: #wall; addPart: EnchantedRoom named: #room; addPart: DoorNeedingSpell named: #door; yourself)

S.Ducasse 13 Implementation: Using the Factory MazeFactory>>createMaze: aFactory | room1 room2 aDoor | room1 := (aFactory make: #room) number: 1. room2 := (aFactory make: #room) number: 2. aDoor := (aFactory make: #door) from: room1 to: room2. room1 atSide: #north put: (aFactory make: #wall). room1 atSide: #east put: aDoor.... room2 atSide: #south put: (aFactory make: #wall). room2 atSide: #west put: aDoor. ^ Maze new addRoom: room1; addRoom: room2; yourself MazeFactory>>make: partName ^ (partCatalog at: partName) new

S.Ducasse 14 Abstract Factory Collaborations Collaborations Normally a single instance of ConcreteFactory is created at run-time AbstractFactory defers creation of product objects to its ConcreteFactory subclass

S.Ducasse 15 Consequences It isolates concrete classes It makes exchanging product families easy It promotes consistency among products Supporting new kinds of products is difficult (set of products is somehow fixed) The class factory “controls” what is created

S.Ducasse 16 Using Prototypes The concrete factory stores the prototypes to be cloned in a dictionary called partCatalog. make: partName ^ (partCatalog at: partName) copy The concrete factory has a method for adding parts to the catalog. addPart: partTemplate named: partName partCatalog at: partName put: partTemplate Prototypes are added to the factory by identifying them with a symbol: aFactory addPart: aPrototype named: #ACMEWidget

S.Ducasse 17 In Relations Builder and Abstract Factory are closely related But Builder is in charge of assembling parts AbstractFactory is responsible of producing parts that work together

S.Ducasse 18 Known Uses VisualWorks UILookPolicy