Re: Re: Enforce a constant in a class.

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

 



2010/1/22 Pete Ford <pete@xxxxxxxxxxxxx>:
>
> IMHO, a constant is not the correct beastie in this case - if you want it to
> be different depending on the implementation then it ain't a constant!
>
> You should probably have protected static variables in the interface, and
> use the implementation's constructor to set the implementation-specific
> value (or override the default)
>
> interface SetKillSwitch
> {
>        protected static $isSet = TRUE;
>        protected static $notes;
>        protected static $date = '2010-01-22T11:23:32+0000';
> }
>
> class KilledClass implements SetKillSwitch
> {
>        public function __construct()
>        {
>                self::$isSet = FALSE;
>                self::$date = '2010-01-21T09:30:00+0000';
>                self::$notes = "Test";
>        }
> }
>
> Cheers
> Pete Ford

There is the problem. The interface is just saying that a killswitch
has been set. Not the date it was set, nor the notes. Thats specific
to the implentor.

In the implementor, they are constant.

In my mind, the interface is only saying that these elements need to
exist. Not what they are. Just like if I say there must be a method
X() in the interface, I don't define what it does.


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