On Jan 13, 2009, at 10:55 , Ralph Schindler wrote:
First, the __construct($options = array()) {} convention for the most
forward facing component API constructor adds a level of consistency
that
makes each and every component look and feel similar in style. This
would
makes it easy to move from component to component and have a good
understanding of what is expected.
...
I believe this convention is very much used in Solar and its
becoming more
popular in ZF as we see more components hit the library.
Correct. In Solar, it is used always and only; that is, every
constructor for every class is identical:
public function __construct($config = null) { ... }
It helps to standardize configuration of instances and aids greatly in
Dependency Injection and Service Location. I call this a "universal
constructor." I don't know if this pattern has been cataloged anywhere.
You can read a bit more about it on these pages:
- <http://paul-m-jones.com/?p=197> (old but mostly valid)
- <http://solarphp.org/manual:project_standards:constructor_parameters>
--
Paul M. Jones
http://paul-m-jones.com/