On Wed, Apr 30, 2008 at 12:06 PM, Jeremy Privett <[EMAIL PROTECTED]>
wrote:

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


thank you for you response Jeremy.  i understand what interfaces are and i
have stressed their importance and power on php-general more than once.  im
just curious more about what influenced the addition of them to php.  im not
as old as many of them members in the community, so i know there are many
people who have dealt with more languages than i on a daily basis during
their careers.  from my limited base of knowledge, i think java was the
first language to add the keyword 'interface'.  and my presumption is that
that grew from the convention of creating 'interfaces' in c++ by writing
entirely virtual classes (as mentioned in gang of four).  i have heard
different perspectives on this, but i figured, what better place to get to
the bottom of it than to ask the people who decided to add the interface
construct to php in the first place.

-nathan

Reply via email to