Nathan Nobbe wrote:
all,

in recent weeks there has been a lot of arguing about what interfaces are,
arent (on php-general and now on the internals list as well) etc. etc.

i am quite curious, why interfaces were added to the language in the first
place.  note, i am not criticizing them, i am overjoyed that the language
has them, however i am curious about the history.  is this something php
borrowed from java?  does it have anything to do with 'entirely virtual
classes' in c++ ?  i think that the history behind the addition of
interfaces to php, would shed a lot of light on their intended purpose for
use by php developers.

thanks,

-nathan


"Interfaces" exist in different OO-enabled languages. PHP strengthened its object model in PHP 5, and thus the introduction of interfaces. I'm pretty sure the intended purpose of interfaces was just like pretty much every other language. You implement interfaces in order to provide a consistent API. As long as class A implements interface B, I can be for certain that it's going to contain methods C and D. Interfaces also give you the ability to "type hint" against them, requiring objects that implement that interface, thus ensuring you know what methods are on that object.

Interfaces are a very powerful feature, when implemented properly.

--
Jeremy Privett
C.E.O. & C.S.A.
Omega Vortex Corporation

http://www.omegavortex.net

Please note: This message has been sent with information that could be 
confidential and meant only for the intended recipient. If you are not the 
intended recipient, please delete all copies and inform us of the error as soon 
as possible. Thank you for your cooperation.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to