This article describes the Abstract Factory Design Pattern design pattern. This is a creational design pattern, a category of design pattern used by software engineers, when writing computer programs.
The Abstract Factory Design Pattern pattern is a design pattern, used in software engineering to grouping similar objects without needing to specifying their concrete classes. This allows the developer to outline the methods and objects of the final concrete factories, so that all share an expected set of methods and classes. Objects are typically just represented as interfaces, allowing concrete objects to be varied, but always have the important shared features. This pattern defines an Abstract Factory (CarFactory) which has Abstract Products (ICar), which is used by the Client to create Concrete Factories (SaloonCarFactory, HatchbackCarFactory) with Concrete Products (SaloonCar, HatchbackCar) This pattern is defined as a Creational design pattern because it defines the base templates for factories that create objects.
↑ Return to Top
Allows the application to be more portable and extensible. Allows new derived types to be added, without changing any core/shared properties or methods. Reduces the amount of conditional logic needed (eg "if car is Saloon, do this, else do that")
A Real world example would be a car factory, that produced several models of car. You would instantiate a concrete implementation of the "car factory" class to make a saloon car, or hatchback model. That concrete factory can both make cars, totally different cars, but both factories have "AddWheels" and "InsertEngine" methods. Each of the resulting car objects have Colour and NumberPlate properties, as well as Brake and Accelerate methods, because all cars are of type ICar.
XAML guy edited Revision 2. Comment: updated
XAML guy edited Revision 1. Comment: counter
XAML guy edited Original. Comment: tidied sections