Originally posted by Paul Keohan:
I think I get the difference between these patterns. The difference in my mind is basically, the AF pattern is for when your client maye not even know the factory type. But the FM pattern implies one factory creating different objects.
Originally posted by Ilja Preuss:
Well, there are some possible other reasons to prefer the decoupling:]
- Reduced compile time dependencies: Without the interface, whenever you change the adapter, the Button needs to be recompiled.
Sometimes, an Application (or framework) at runtime, cannot anticipate the class of object that it must create. The Application (or framework) may know that it has to instantiate classes, but it may only know about abstract classes (or interfaces), which it cannot instantiate. Thus the Application class may only know when it has to instantiate a new Object of a class, not what kind of subclass to create.