ABSTRACT FACTORY PATTERN IN C++
The Abstract Factory pattern is mostly common in C++ code. Many libraries and frameworks use it to provide a way to extend and customize their standard components.
The Abstract factory pattern is easy to recognize by methods, which in turn returns a factory object. After wise, the Abstract factory is used for creating specific sub -components.
Abstract Factory is a creation design pattern, which solves the problem of creating entire product families without specifying their concrete classes.
Abstract Factory defines an interface for creating all distinct products but leaves the actual product creation to concrete factory classes. Each Abstract factory type corresponds to a certain product varieties.
The client code calls the creation methods of a abstract factory object instead of creating products directly with a constructor summon (new operator).
Since an abstract factory corresponds to a single product variant, all its products automatic become compatible.
Client code works with factories and products only through their abstract interfaces. This lets the client code work with any product variants, created by the abstract factory object. You just create a new concrete factory class and pass it to the client code.
ABSTRACT FACTORY
As stated earlier that abstract factory provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes, now we base upon when one is to consider the use of the Abstract Factory.
INSTANCES IN WHICH WE USE ABSTRACT FACTORY
● When a system is independent of how its
products are created, composed, and represented.
● When the system is configured with one of multiple families of products.
● When a family of related products is designed to be used together and need to enforce this constraint.
● You want provide a class library of products and you want to reveal just their interfaces not their implementations.
UNIFIED MODELING LANGUAGE (UML) DEMO
Unified Modeling Language (UML) is also a standardized modeling language consisting of an integrated set of diagrams, developed to help system and software developers for ,constructing, visualizing, specifying, and documenting the artifacts of software systems, as well as for business modeling and other non - software systems.
Uml is of a great importance because of it's ability to generate code in various languages using the diagrams designed.
UML has a direct relation with object -oriented analysis and design in programing.
Generally, UML benefits are as highlighted below in the summary notes;
• It helps you visualize a system.
•It provides template that guides you in constructing the whole system.
•UML documents the decisions that one has come up with.
•It also permits someone to specify the structure or behavior of the whole system.
UML OF ABSTRACT FACTORY IN C++
In this format, the UML starts with creating a class of Abstract Factory, in this class two main methods are involved /created.
In hear,the normally created methods are the Scrollbar and the window.
I.) createScrollbar()
II.)createWindows()
With this and when some conditions hold, two main classes should be created that is the ConcreteFactory1 and ConcreteFactory2.
In ConcreteFactory1 two main products /methods are created, the two products include product A and product B respectively.
This is the way they should name the products in your UML Dem, you should declare;
for • ConcreteFactory1 > createProductA()
> createProductB()
In ConcreteFactory2 also two main products / methods are created, the two products include product A and product B respectively.
This is the way you should name and declare the products in your UML Dem;
for • ConcreteFactory2 > createProductA()
> createProductB()
Out of this two ConcreteFactory that is; ConcreteFactory1 and ConcreteFactory2 respectively with their products , two Abstract factory will be displayed to the client code.
This Abstract Factory are the Abstract factory for product A and for product B.
They are displayed in this this design in a UML diagram /demo;
•AbstractProductA
•AbstractProductB
When some conditions hold, AbstractProductA give out two outputs. It should gives ProductA1 and ProductA2 output.
This is the representation you should have ;
•AbstractProductA > ProductA1
> ProductA2
Likewise, when some conditions hold, AbstractProductB gives out two outputs too. It should give ProductB1 and ProductB2 output.
This is the representation you should have ;
•AbstractProductB > ProductB1
> ProductB2
No comments:
Post a Comment