> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Guyren Howe
> Sent: Friday, August 25, 2006 1:24 PM
> To: REALbasic NUG
> Subject: Re: RB code Hacks
>
> On Aug 25, 2006, at 12:55 PM, Walter Purvis wrote:
>
> >> 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
> >
> > That makes sense. What would be good is to have an
> interface, call it
> > InstanceFromClassName, with two methods, Instance (as decribed
> > above) and
> > ClassName (as described earlier in thread -- it simply returns the
> > name of the class).
> >
> > Then any class you want to be instantiable (that's probably not a
> > word) just
> > has to implement that interface and it can be registered with the
> > factory (which presumably would store the registered
> > InstanceFromClassName-implementing objects, i.e., the
> mini- factories,
> > in a dictionary), using a Register(instance as
> InstanceFromClassName)
> > method.
>
> 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?
_______________________________________________
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>