Re: Enforce a constant in a class.

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

 



Op 1/22/10 4:55 PM, Richard Quadling schreef:
> 2010/1/22 Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
>> 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.

constants in interfaces are not meant for this. a class constant doesn't
constitute an interface. I believe constants in interfaces are allowed purely
because it is helpful to have them defined outside of the global space and
somewhere where all implementors of said interface can realiably reference them.

I would suggest you need to define some extra methods in your interface e.g.

	function getKillNotes();
	function getKillTypeFlag();

> 
> 
> --
> -----
> 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
> 


-- 
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