On Aug 25, 2006, at 10:20 AM, Guyren Howe wrote:

Permit me to elaborate. A factory function is a good solution to this, but it doesn't provide what the original person was looking for, which is something more loosely coupled and easily extensible. But first-class classes, suitably designed, do.

If classes were themselves objects, with constructors and able to support polymorphism (a "Shared Interface", meaning the shared methods on the class allow the class to be treated as an instance of a type), then in the class's constructor, it can register itself with the factory, installing itself into the dictionary you suggested, and manufactures instances of itself on request. Now, the factory works as in your solution, but the code is more loosely coupled: you can add new classes, delete classes, whatever, and you never have to change the factory.

I really have not been following this thread very closely, but has anyone considered Shared Methods? Instead of making an object factory, why not make the object itself be responsible for creating an instance of it's type?

Something like:

  [Shared] Function Instance() As MyClass
    Return New MyClass
  End Function

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to