I think the biggest problem I encountered is that the goal of the factory is for the client code to be able to create a derived instance of the object without knowing the details of the type being created (more precisely, the details of how to instantiate, but if everything is done correctly, the caller does not need to know any of the finer details except what is provided by the base class).
Using type information extracted from a derived type still requires the caller to have some intimate knowledge of what type he wants to create, making updating and maintenance difficult. By replacing the Enum type (or string, int, etc.), you can update the factory without updating the calling code to be aware of the new derived types.
I suppose it can be argued that the type name can be read as a string from the configuration file, database, etc., and the type information is determined using Reflections (in .NET) or RTTI (in C ++), but I think that this is the best case for simply using a type string as your identifier, as it will serve the same purpose effectively.
jeremyalan
source share