Re: class attributes and __construct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 15 April 2010 08:37:40 am Ashley Sheridan wrote:

> I know I could move it to __construct and give it a default value in the
> arguments list, but that brings it's own problems. What if the argument
> list grows too big, and which attribute would be deemed more important
> than another that you might want to override it without specifying every
> other? Is there a rule of thumb as to what belongs in __construct and
> what does not?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

I tend to favor setting the default with the property itself rather than in 
the constructor, even if I expect the constructor to specify it.  I really 
really hate having undefined variables. :-)  So even if, for instance, I'm 
going to pass in a db connection object in the constructor I will define it in 
the class and set it to NULL rather than not setting to anything.

OK, I'm a little OCD, but it works. :-)  

--Larry Garfield

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux