January 06, 2015

Design Patterns - Abstract Factory Pattern

What?
A more special and complex version of the Factory Pattern. The additional complexity is that the not only does the client now know the actual object being created but also does not know the Factory which is creating the object i.e. the Factory now also configurable.

Why?
Used in Dependency Injection. The pattern does not have the actual types that it needs to create but might have some way to create them based on information passed to it like the type name.

How?
In .NET reflection can be used to create instances using type names as strings see Activator.CreateInstance.



http://stackoverflow.com/questions/2280170/why-do-we-need-abstract-factory-design-pattern