Re: oo design question - how to avoid a factory

From: Date: Tue, 21 Dec 2004 16:14:23 +0000
Subject: Re: oo design question - how to avoid a factory
References: 1 2 3 4 5 6 7 8 9  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35199@lists.php.net to get a copy of this message
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. 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. -- og

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