Gang of Four Patterns
In the last lecture I learned about the Gang of Four patterns and I was able to get a brief knowledge about the 23 three patterns involved. In the is 23 patterns I would like to elaborate on one of the patterns in to depth it is the Abstract Factory Pattern
Name
Abstract Factory provides an interface for common and related objects without specifying their classes.
Intent
Converts the interface of a class into another interface clients expect. Adapter lets classes work together.
Known As
Abstract Factory is also known as a Kit
Motivation
Cannot use a toolkit or a class library , because the interface may differ to the required interface of the application.
Library interface cannot be changed without the source code.
A Library cannot be changed for each particular application.
Structure
Multiple Inheritances is used by a class adapter to communicate from one interface to another
Applicability
Can be applicable in an existing class, when the particular interfaced doesn’t suite with one required. Applicable to create reusable classes which can retaliate with uncommon class and unsuitable interfaces
Participants
Abstract Factory
Key role of establishing interface which functions to create objects of abstract product.
Concrete Factory
Establishes the functions to create objects of concrete product
Abstract Product
Establishes an interface to product object
Concrete Product
Describes a product object which will be created by the particular concrete factory
Client
Can use the interface defined by classes of abstract factory and Abstract Product
Collaborations
An instance of a concrete factory is created at runtime.
A concrete factory creates product objects which have implementation. A client should use different concrete factory to create different product objects.
Consequences
Classes created by an application are continued by the Abstract Factory. It is responsible for the encapsulation and creating of product objects. Clients are not involved in abstract interfaces. Product classes’ names are not involved in implementing concrete factory
Exchanging of product families is made easy, because a class of a concrete factory appear only once in an application.
This makes a concrete factory of applications changeable at anytime.
Can use different configurations by changing the concrete factory. Product objects designed in an abstract factory working together.
Implementation
Creating products
Defining extensible factories.
Sample Code
This element illustrates a sample of a source code how a Adapter Pattern can be applied practically to a problem
Known Uses
Windows Applications, Creation of Scrollbars, Menus, Submenus, Buttons etc.
Business Applications, to create required applications e.g. click events
Related Patterns
Singletons – a concrete factory.
Subscribe to:
Post Comments (Atom)
2 comments:
Hi, in your own view do you think this pattern is really useful? Hope am not asking too much, would like to know your view/opinion.
Cheers
Hi
I have view your pattern on the group of four element of pattern of which you have choose to write on Abstract factory pattern. When i went through the writeup it was so interesting and you have make me to understand abstract factory. although i prefer Alex element of pattern because it is very straight forward than the group of four. It is nice reding your pattern and try to keep it up.
Post a Comment