The Abstract Factory pattern provides an interface for creating families of related objects without specifying their concrete classes. It is a creational pattern and falls under the category of object-oriented design patterns.
Here's an example implementation of the Abstract Factory pattern in C#:
main.cs1184 chars59 lines
In this example, we have two concrete product classes (ProductA
and ProductB
) and two concrete factory classes (FactoryA
and FactoryB
). The Client
class takes an instance of an IFactory
during construction, and then uses this factory to create an instance of the relevant product (ProductA
or ProductB
). This allows the client to use different products without having to worry about their concrete classes.
gistlibby LogSnag