On Mar 12, 10:31 am, dave_mikes...@fastmail.fm wrote:
The GoF book implements the patterns in C++, and some of
them don't make a lot of sense in other languages. For
instance, in Python you can instantiate an object by only
knowing its class name, somewhat obviating the need for
your own abstract factory.
How does that follow? The point of Abstract Factory is that
the factory's clients don't have to know the exact types
being instantiated. The GoF example is a GUI widget
factory; if the client code wants a button, it shouldn't
have to know the exact type that will be used to instantiate
the button.
Do you mean that client code should be passed a bunch of
string variables a priori, as in "here's your button class
name, here's your scroll-view class name," etc? That's not
anywhere near as flexible as Abstract Factory. The factory
lets you delay the decision of which object type to
instantiate, right up to the moment you need the object.