On Aug 25, 2006, at 1:35 PM, Walter Purvis wrote:

 This would work if we had first-class classes. But we don't,
 and right now, you can't treat a class as an object in this
 way. The shared methods and properties make a class *almost*
 exactly like a module at the moment.

The original request was
Does anyone know of any code hacks that would allow a developer to
instantiate a custom class from within the IDE by name?

example:
dim instance as Object = NewInstanceOfObjectByName("MyCustomClass")

Except for the limitation that it wouldn't work for just any old class -- it
would only work for classes that implement the InstanceFromClassName
interface -- wouldn't the factory approach above do exactly what he wants?

The benefit of using a combination of classes with shared interfaces and constructors is that your code is more loosely coupled -- you can add or remove classes from the factory without having to modify the factory. This doesn't sound that exciting when you discuss one factory in isolation, but in a sufficiently complex application, the much better modularity and looser coupling makes maintenance easier. No running around, trying to remember "when I create a Foo, I have to remember to add it to this factory, and that other thing, and this thing over here" -- everything you need to do, you can do inside Foo.

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
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