Re: db abstraction: pass by reference versus return

From: Date: Thu, 11 Jul 2002 16:04:23 +0000
Subject: Re: db abstraction: pass by reference versus return
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7665@lists.php.net to get a copy of this message
le 11/07/02 17:53, Martin Jansen à mail@martin-jansen.de a écrit : > On Thu Jul 11, 2002 at 04:1630PM +0200, Lukas Smith wrote: >> 1) The question is about if methods should always either return DB_OK or >> an error object and any return data should be placed into a var that is >> passed by reference. >> >> 2) Alternatively the method can either return the data or an error >> object. ("the PEAR DB way"). > > For the records: That's my favourite way and I'm for sticking to > it. The reasons for this are described below. > >> 3) Finally we can have a mix. If this is the option then we need to >> decide what methods should work which way ("the Metabase way"). > > Mixing both ways will create inconsistency in the package, which > generally is a bad thing. > >> I think this is a major useability question so I just wanted to ensure >> that this is done the way people really want it to be. >> >> Somehow 1) seems like the comp sci way of doing things as it just feels >> cleaner to me. :-) > > Yeah, may be, but IMHO 2) is just more intuitive, since people are > used to work this way: Nearly all PEAR packages work this way right > now. Using 1) in MDB/DB will cause a bit of inconsistency then because > we'll have 99% of the PEAR packages using 2) and just 1% using 1). IMO, inconsistency comes when you don't know what the method you call will return. It has always been weird for me to think that a DB result object could end up being a BD error object. I think 1) is more intuitive because we know what the result will be and also because it is a lighter solution when there are no errors. So +1 for 1) Bertrand Mansion Mamasam

« previous php.pear.dev (#7665) next »