RE: [PEAR-DEV] Re: [PEPr] Proposal for Database::DB_Table

From: Date: Wed, 07 Jan 2004 16:26:35 +0000
Subject: RE: [PEAR-DEV] Re: [PEPr] Proposal for Database::DB_Table
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24861@lists.php.net to get a copy of this message
> From: Paul M Jones [mailto:pmjones@ciaweb.net] > Sent: Wednesday, January 07, 2004 5:20 PM > On Jan 7, 2004, at 9:56 AM, Lukas Smith wrote: > > Under a factory method, the only way to extend a class directly is to > specify the extended class name in the factory call; I find this to be > not-that-friendly. Why would I specify the class name when I already > "know" what class I'm calling? > > If someone extends the original class, all the Factory() calls need to > be updated to use the new class name. In theory, one might be able to > get_class($this) to get the current class name in the Factory() method, > but since a factory method is static, there is no $this to look at. If > you make the factory non-static, then you might as well make it the > constructor. > > Do you see what I mean? Factories are good in many cases, but in this > one (direct extension of a class) I think it's not the right solution. The point is that you tell the factory what type of object you want. So this would mean that your factory could now return classes of the old new etc type. Function factory($type) { Return new $type; } Regards, Lukas

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