Re: oo design question - how to avoid a factory

From: Date: Mon, 20 Dec 2004 21:26:58 +0000
Subject: Re: oo design question - how to avoid a factory
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35186@lists.php.net to get a copy of this message
Justin Patrin wrote:
On Mon, 20 Dec 2004 09:59:52 -0500, Andrew Nagy <andrew.nagy@villanova.edu> wrote:
Olivier Guilyardi wrote:
Now, there may be another solution, to keep bc : In the constructor, issue a warning like "Please use the factory...", and then act as a decorator to the real datagrid. This is very possible because the Structures_DataGrid class is currently an almost empty wrapper.
     
Here is what I would like to do. I have implemented your diff that you sent me, however instead of removing the datagrid from the constructor of the render drivers I have left that in so that PHP5 users don't have to use the factory method. How does this sound? I will check it into CVS for you to see
In other words, it will silently break on PHP4 if you use the constructor? And also, you have two different syntaxes for different PHP versions. Part of the argument above is that factories aren't hard to make users use....as long as you tell them that they have to use it. I guarantee that if you allow both users *are* going to use the 'new' method much more often than they should be. Agreed, however, I would like to leave the syntax the same so that when PHP5 does become the de facto, it will make the transition very simple.
If the 'new' method is used in php4, it will break silently, which I assume is bad, but since everyone seems to think it doesn't matter as long as I say how to use it in the documentation, it's not all that bad. Thoughts? Andrew

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