RE: PHP object communication
| From: | ad at m dot beecher dot net | Date: | Tue, 30 Oct 2001 01:50:52 +0000 |
| Subject: | RE: PHP object communication | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72805@lists.php.net to get a copy of this message | ||
Sorry, it was Tim that suggested that what I required wasn't really OO. My
apologies Tim, and thanks for your emails.
adam
____________________________________________
Adam Beecher - CEO & Core Geek - ieWebs
e ... ad@m.beecher.net
w ... http://www.iewebs.com
m ... Box 81, Eglinton St, Cork, Ireland
____________________________________________
> -----Original Message-----
> From: Tim Ward [mailto:tim.ward@stivesdirect.com]
> Sent: 25 October 2001 12.04
> To: ad@m.beecher.net; Tim Ward; php-general@lists.php.net
> Subject: RE: PHP object communication
>
>
> see below for comments
>
> Tim Ward
> Senior Systems Engineer
>
> Please refer to the following disclaimer in respect of this message:
> http://www.stivesdirect.com/e-mail-disclaimer.html
>
>
> > -----Original Message-----
> > From: ad@m.beecher.net [SMTP:ad@m.beecher.net]
> > Sent: Thursday, October 25, 2001 11:56 AM
> > To: Tim Ward; php-general@lists.php.net
> > Subject: RE: PHP object communication
> >
> > Hi Tim,
> >
> > > If you want access to error functions within the db class it
> must either
> > > extend the error class or have an error object within it. Either ...
> > >
> > I'll go for the latter, because extends isn't appropriate in this case:
> [Tim Ward] I think I would use the second option in your case as
> well, but always consider inheritance, it's beter where it is appropriate
>
> > > Class DB
> > > { var $error;
> > > ...
> > > function DB() // constructor
> > > { ...
> > > $this->error = new Error();
> > > }
> > > ...
> > > }
> > >
> > > Class Core
> > > { var $db;
> > > var error;
> > >
> > > function Core() // constructor
> > > { ...
> > > $this->db = new DB();
> > > $this->error = new Error();
> > > ...
> > > }
> > > }
> > > at the end of the day, both these are ways of getting around the
> > > lack of multiple inheritance
> > >
> >
> > In this case, don't I have a completely different error object in
> > $Core->db?
> [Tim Ward] Yes, which is exactly what you want.
>
> the classes DB and Core both need to handle their own errors.
> What you don't
> want to do is handle errors in DB within an instance of Core. That would
> mean DB cannot cannot function except as part of Core. Remember .. there
> are 2 O's in OOP, the second one is important. Each class should be
> complete. if you try to get DB to use error functions defined (or
> inherited
> by) in Core you are effectively trying to get a parent to inherit from a
> child.
> >
> > adam
>