Abstract Factory Design Pattern Uses
In this example we ll create two implementations of the factory method design pattern.
Abstract factory design pattern uses. Abstract factory patterns work around a super factory which creates other factories. An interface for creating families of related or dependent objects without specifying their concrete classes. After that we ll manage access to them using an abstract factory abstractfactory. We should use the abstract factory design pattern when.
Here s the animal interface. This factory is also called as factory of factories. The abstract factory pattern is a creational gang of four gof design pattern defined in their seminal book design patterns. The system is or should be configured to work with multiple families of products.
In normal usage the client software creates a concrete implementation of the abstract factory and then uses the generic interface of the factory to create the concrete objects that are part of the theme. In this article i have tried to cover the concept of abstract factory design pattern and the ways of implementing abstract factory design pattern. The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes. Abstract factory design pattern is one of the creational pattern.
This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. First we ll create a family of animal class and will later on use it in our abstract factory. Now let s move on to the abstract factory design pattern. A family of products is designed to work only all together.
The system needs to be independent from the way the products it works with are created. Abstract factory patterns work around a super factory which creates other factories.