Well this is just a suggestion since I am in the middle of some PostgreSQL
learning and I don't entirely know your situation.. BUT...

In times like this, I usually build one MASTER OBJECT to controll all the
other little happy citizen objects like mindless sheep.

For instance.  At one point I needed Form objects ( think of your bus ) to
not only have access to other objects called Style objects, which could
change ( think of your diesel object ), but also communicate to a database
and do all sorts of other fun stuff. Now.. I couldn't have random objects
floating around in orbit cause then they couldn't talk to each other so
well, and things would get frustrating and one of the objects was likely
to punch one of the other objects, knocking out his front properties.  I
couldn't afford the dental.

So what I did was create a "FormMaster" which held methods for accessing
individual objects, makeing all the objects do the same thing ( whether
they complained or not ), letting the objects access (indirectly) the
properties ( think 'global, but not' ) of the master object, and it all
stays very neat.

of course.. it's more coding... hehe.. but it made my forms behave quite
nicely.

regards,
dan



 Fri, 6 Sep 2002 17:45:33 -0500
Paul Smith <[EMAIL PROTECTED]> wrote:

> Other classes need to have access to these objects without going 
> through any mode objects. I suppose I can just pass by reference to 
> these other classes; I don't want to have any objects out of sync.
> 
> On Friday, September 6, 2002, at 06:12  PM, Dan Ostrowski wrote:
> 
> > The only point I don't understand is why you are averted to saying
> > $bus->setFuel($diesel); I don't understand the drawback...
> >
> > regards,
> > dan
> >
> >
> > On Fri, 6 Sep 2002 16:58:06 -0500
> > Paul Smith <[EMAIL PROTECTED]> wrote:
> >
> >> I'm compositing a class based on other classes. The component classes
> >> are (this is for a transportation application) fuel and vehicle. The
> >> container class is mode (as in mode of transit: rail, bus, etc.). 
> >> There
> >> can be several vehicles and fuels for each mode (many to one). I want
> >> to be able to accomplish something like this:
> >>
> >> $bus = new mode();
> >> $diesel = new fuel($bus);
> >> $ethanol = new fuel($bus);
> >> $class_a_bus = new vehicle($bus);
> >> $articulated_bus = new vehicle($bus);
> >>
> >> In other words, register the fuels and vehicles with the mode object 
> >> in
> >> such a way that I don't have to make them members of said object; in
> >> further other words, instead of doing it something like:
> >>
> >> $bus = new mode();
> >> $diesel = new fuel();
> >> $bus->addFuel($diesel);
> >>
> >> Is there a way I can then reference the components of the mode object
> >> without having to know the names I picked for the variables; without
> >> having to do something like:
> >>
> >> $diesel = new fuel();
> >> $bus->addFuel($diesel, 'diesel'); <-- a handle to reference the
> >> globally scoped variable
> >>
> >> One kludgy way would be to foreach() the $GLOBALS in a method of the
> >> mode class, checking for is_a('fuel'). One of my rules of thumb is to
> >> reduce use of the $GLOBALS. Would a more elegant solution be related 
> >> to
> >> PHP's reference counting? I apologize if this is a confusing-as-hell
> >> post. I would be more than happy to clarify a point...
> >>
> >> Paul
> >>
> >> --
> >> Paul Smith <[EMAIL PROTECTED]>
> >> Center for Neighborhood Technology
> >> Chicago, IL USA
> >>
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> --
> Paul Smith <[EMAIL PROTECTED]>
> Center for Neighborhood Technology
> Chicago, IL USA

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to