Pattern Abstract Factory

Slides:



Advertisements
Similar presentations
Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
Advertisements

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.
Ch 12: Object-Oriented Analysis
© 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:
Plab – Tirgul 12 Design Patterns
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Object-oriented Programming Concepts
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Abstract Factory Pattern.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Design Patterns.
Creational Patterns (1) CS350, SE310, Fall, 2010.
Prof. Hertz (as told by xkcd.com)‏. Computer Science 313 – Advanced Programming Topics.
Abstract Factory Design Pattern making abstract things.
Software Components Creational Patterns.
The Factory Patterns SE-2811 Dr. Mark L. Hornick 1.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Structural Design Patterns
Unit 2 Architectural Styles and Case Studies | Website for Students | VTU NOTES | QUESTION PAPERS | NEWS | RESULTS 1.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Part VII: Design Continuous
The Factory Method Design Pattern Motivation: Class / Type separation – Abstract class serves as type definition and concrete class provides implementation.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
CS 590L – Distributed Component Architecture 02/20/2003Uttara Paingankar1 Design Patterns: Factory Method The factory method defines an interface for creating.
Abstraction ADTs, Information Hiding and Encapsulation.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
Advanced Object-oriented Design Patterns Creational Design Patterns.
1 Here are some quotations to get an overview of the kinds of issues of interest.
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.
SOLID Design Principles
Chapter 7 Creational Design Pattern. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed.
Design Pattern: Builder Timothy Holper. The Builder design pattern: What is it? The Builder pattern is a way to: ‘Separate the construction of a complex.
 Creational design patterns abstract the instantiation process.  make a system independent of how its objects are created, composed, and represented.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
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.
Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Cake PHP – OOPS approach for PHP
Design Patterns: MORE Examples
CompSci 280 S Introduction to Software Development
Abstract Factory Pattern
Factory Patterns 1.
Software Design and Architecture
object oriented Principles of software design
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Presented by Igor Ivković
John D. McGregor C8 - Tactics
Object-Oriented Programming
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Lesson 5: More on Creational Patterns
Software Design Lecture : 35.
Presented by Igor Ivković
Presentation transcript:

Pattern Abstract Factory

Definition and motivation Abstract factory is a pattern, generating objects, which provide an interface for creating a collection of logically related or dependent objects without specifying concrete classes. The system should not depend on how to create, assemble and submit the incoming objects. The objects built in certain way are simply served at the entrance. Objects of one collection should be used together. Specific variant of the desired behavior of the system are given by not separate objects, but by the collection of related objects. For the functioning of the systems you need one of such collection of related objects. The system input is only the whole collection of such objects. You want to provide a library of objects, revealing only their interfaces, but not the implementation.

Advantages The implementation of concrete classes are hidden. The factory isolates the client from the implementation details of classes. It encapsulates the responsibility for creating classes. The client only know interfaces, abstract classes through which it can perform its business logic further. Free replacement of product collection. The application can change the configuration of objects, simply substituting a new concrete factory. Warranty use of only one type of objects. If certain collection of objects designed for the joint purposes, it is important that the application in each moment can work with only a single collection of objects. Class AbstractFactory allows you to maintain this limit easily. Simplified testing. When testing it is easy to replace a whole collection of objects with another set of classes.

Class diagram

Participants AbstractFactory is the abstract factory. Announces a common interface for creation of abstract objects. Further the concrete objects of some collection will be produced in the application instead of the abstract objects. ConcreteFactory[N] is the concrete factory. Ii implements the operations that create all objects of the same specific collection. AbstractProduct[A-Z] is the abstract object. It defines a common interface for the object. A-Z are many of such objects, components of an abstract collection. ConcreteProduct[A-Z][N] is a specific object. It defines the specific object of a type [A-Z] created a particular factory [N]. Client is the other software module, obtaining a specific collection of products, using only known interfaces of classes AbstractFactory and AbstractProduct.

Example 1 Consider the production of cars and engines. We define the entities “car”, “engine” and factories, creating these entities.

Example 1 Implementation of the entity of the car “Ford” and the corresponding engine:

Example 1 The factory, which is responsible for creation of automobiles and engines “Ford”:

Example 1 Implementation of the entity of the car “Toyota” and corresponding engine:

Example 1 The factory, which is responsible for creation of automobiles and engines “Toyota”:

Example 1 Consider the example of the use of factories:

Example 2 Consider the example of using “Abstract factory” pattern to support addresses and phone numbers of different countries. Each country has its own telephone code and standard of address record. The interface of a factory, creating the objects of addresses and telephone numbers, is the following:

Example 2 Below the base class address is specified:

Example 2 The base class of the phone number:

Example 2 A concrete class that represents US addresses:

Example 2 A class representing the US telephone numbers: The factory, which instantiates the instances of the US address and phone number:

Example 2 A concrete class that represents France addresses:

Example 2 A class representing the France phone numbers: The factory, which instantiates the instances of the France address and phone number:

Example 3 Suppose we are writing a game in which the player will meet with a variety of enemies: soldiers, monsters and supermonsters. All enemies, who will meet the player, must correspond to the level of complexity that is selected in the beginning of the game. The factory for creating enemies could be the following:

Example 3 The factory which creates enemies with for low complexity:

Example 3 The factory which creates enemies with for high complexity:

Example 3 This approach has the following disadvantages: Duplication. When implementing factories, we have to repeat the same code. Inability of generalization. It is impossible to write next general code: We need to call concrete factory methods.

Example 3 We can get rid of these disadvantages if the class of abstract factory is given a list of parameters in the form of types that it should create: Then the function of creating objects could be called from general code:

Lists of types For realization of these factories there is the concept of list of types in the Loki library. This list of types is defined so: To determine the list of types of random length the recursion is used. For example, a list of the types of three elements looks like this:

Example 3 In addition, the library contains a set of macros for simplified definition of the list of types: These macros are used thus:

Example 3 Loki library contains a mechanism for creating abstract factories. The class “AbstractFactory” is used. It takes a list of types as a parameter:

Example 3 To identify concrete factories the class “ConcreteFactory” must be used:

Example 3 As a result it is possible to use the factory in the following generalized functions: The code that uses this function might be: