Re: oo design question - how to avoid a factory

From: Date: Tue, 21 Dec 2004 17:57:18 +0000
Subject: Re: oo design question - how to avoid a factory
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35203@lists.php.net to get a copy of this message
On Tue, 21 Dec 2004 17:14:23 +0100, Olivier Guilyardi <ml@xung.org> wrote: > Andrew Nagy wrote: > > Andrew S. Nagy wrote: > > > >> After playing around more with the example on the php site: > >> http://www.php.net/manual/en/language.oop.newref.php > >> > >> I tried doing this with out the factory: > >> > >> $dg =& new Structures_DataGrid(20); > >> > >> And everything seems to work except for the data, but i think that is > >> a bug somewhere because I am getting the paging data before calling > >> any render methods. > > > > > > Yep, it was a bug! Instantiate SDG as a reference allows everything to > > work. I don't totally understand it at the moment, but it works! > > > > I am going to check the code into CVS, can you test it on PHP5? > > It works fine in both PHP4 and PHP5 (no warning in E_STRICT mode). > > I find this kind of "=& new" syntax weird : with a factory it's always > needed > to use the & operator so it's coherent, but with a constructor it's an exception > required by 1 package among 10. I have seen other package which do this as well. The XML_Parser, for example, would parse everything fine but I wouldn't get anything from the class unless I used =& when I instantiated the object. This is a strange PHP4 bug. > > Anyway, the good point is that in PHP5 it works fine wether you use "=" or > "=&". > So, it gets coherent : using "=&" is a workaround for a PHP4 bug/limitation. > -- Justin Patrin

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