Abstract Factories: Summary
Table of Contents
Summary
The FactoryProvider
class and the abstract factories allow injecting other concrete implementations. There is also no declaration hell as in the dependency injection example. If you need a different implementation, all you have to do is implement the new class with the associated factory. Create an instance of the FactoryProvider
and pass an instance of the new factory to the constructor, that's it! If everything is fine as it is, then you don't need to do anything. Configuration by exception. Factory providers can be designed as flexibly as you like, it would be conceivable, among other things, to use a dictionary internally so that factories can be registered.