[Gambas-user] 38 different classes - all exactly the same.
Fabien Bodard
gambas.fr at ...626...
Wed Sep 5 12:00:51 CEST 2012
For properties on the fly ... Why dont you use _get ?
Le 5 sept. 2012 11:58, "Bruce" <bbruen at ...2308...> a écrit :
> On Tue, 2012-09-04 at 18:21 -0300, Fabián Flores Vadell wrote:
> > > What I'd like to be able to do is have only one of these, rather than
> > > 38.
> > >
> > > The reason that the metadata is held as a static attribute is that
> > > during any execution of a given program, there might be hundreds
> > > (sometimes thousands) of, say, Horse objects created. So it makes
> sense
> > > to only load the metadata once and share it amongst all the BO's of
> that
> > > type.
> >
> > I think you could move the shared behaviour to the Persistor class,
> > and use a class collection (defined as static private in Persistor) to
> > save the name of each of your current 38 classes, linked to the
> > references to the corresponding instances of BOMeta. In this way you
> > would have just one reference to a BOMeta object for each key in the
> > collection.
>
> That looks to be the solution! Two of us have been looking at this for a
> few days and neither came up with that idea.
>
> > (If you find that the prev option isn't good enought, you could create
> > just one subclass of Persistor with the mentioned collection.)
>
> Probably not necessary.
>
> >
> > In the next future, if you discover the need to have _p*BO classes
> > (i.e. if you found differents behaviours for they) you can add the
> > hierarchy of relevant classes.
>
> That's what the original design concept "thought". But, due to the
> general wonderfulness of Gambas, the need has gone away.
>
> >
> > > So, is there some way to create a class i.e. a new class not a new
> > > object, based on that common code at runtime?
> >
> > I think is impossible because Gambas isn't reflexive. I tried to hack
> > the Gambas features in order to do this, just for fun, but I failed
> > miserably :-(
> >
> > Anyway, if would be possible to do, you will end with a kludge, and
> > you can't warrantee that the ugly hack will work in the next Gambas
> > release.
>
> But, thanks to you this is no longer needed!
>
> Now, if there was only a way to create Properties on the fly ...
> Nah!, I'll leave that one up to the Gods. :-)
>
> >
> > Regards.
> > Fabián.
>
> Fabián,
>
> Thanks for taking the time to look at this. It took us all of today to
> recast the persistor class but it was well worth it as not only did we
> get rid of the specialised persistors but strangely it simplified some
> other aspects.
>
> Please find a few (virtual) beers attached ;-)
>
> regards
> Bruce
>
>
> http://upload.wikimedia.org/wikipedia/en/thumb/6/68/Darwin_stubby.jpg/800px-Darwin_stubby.jpg
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list