Re: Enforce a constant in a class.
| From: | Richard Quadling | Date: | Fri, 22 Jan 2010 15:55:57 +0000 |
| Subject: | Re: Enforce a constant in a class. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301346@lists.php.net to get a copy of this message | ||
2010/1/22 Ashley Sheridan <ash@ashleysheridan.co.uk>
> Constants are there for things that should never change. If you ever need to change them, then
> whoever created the base class either didn't think things through properly, or you're not.
> Imagine a class that sets the value of π (as is the erstwhile example for constants) If further
> classes that implemented it were of a particular historical persuasion, then they might want to
> redefine the constant as just 3. It seemed like a good idea to the historical Roman Catholics at the
> time (it was defined as 3 in the Bible after all) but it doesn't make it the correct value
> (imagine the problems with volume calculations!)
>
> Constants are so called for a good reason!
And in the class that I want to enforce the presence of the constant,
it will be constant.
I just want to enforce the presence.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling