Re: OOP Interfaces



On 19 Jan, 05:52, 703designs <thomasmal...@xxxxxxxxx> wrote:
On Jan 18, 11:48 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:

Curtis Dyer wrote:
On Sun, 18 Jan 2009 15:27:15 -0500, jstuck...@xxxxxxxxxxxxx wrote:
FutureShock wrote:
<snip>
I started reading on Interfaces and I understand HOW to use them, but I
am really foggy on WHY to use them.

<snip>
What other benefits do Interfaces serve?

Scotty
Basically, yes, Scotty.  Interfaces are more important in strongly typed
languages such as java.  They ensure that the implements the necessary
methods.

As you know, PHP is a lot less strongly typed.  But interfaces are still
important, for the same reason.

Aside from this, it seems interfaces would also seem to shine in
teams of developers.  
<snip>

The same benefit goes for programmers who distribute libraries.

Very true.  OTOH, if you have the design properly documented, then
anyone who doesn't implement according to the design gets to go back and
rewrite their code.

Interfaces do make it easier to enforce the design, however.

<snip>

Interfaces are also the only way to get anything close to multiple
inheritance in PHP.

Thomas

Eh? Actually there are ways of implementing multiple inheritance in
PHP (using classkit is probably the simplest) but I can't see what
interfaces (implied or explicit) have to do with it.

Can you enlighten me?

C.
.



Relevant Pages

  • Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
    ... You are confusing member variables with local variables. ... encapsulation, inheritance and polymorphism. ... I have never seen any gain from using interfaces in PHP, only pain, ...
    (php.general)
  • Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
    ... Encapsulation is the act of placing data and the ... as you mark the would-be private variable in php4 private in php5. ... My code has to run using both PHP 4 and PHP 5, so I don't waste my time ... I do not need an interface to access a method, therefore interfaces are ...
    (php.general)
  • Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
    ... OOP is just syntactic sugar to make writing certain logical structures ... achieved through, for instance, interfaces. ... Anything that you can do in PHP you could also do in assembler. ...
    (php.general)
  • Re: Object Oriented Content System - the idea
    ... I expected php to be smarter then that. ... form like bytecode in memory for the next request. ... second generation of framework in Java, ... This whole business of keeping track of interfaces does add considerable ...
    (comp.lang.php)
  • Re: php 5 classes: public, protected and private
    ... This is a PHP newsgroup, not an OO newsgroup, so the discussion of ... interfaces concerns PHP, and in PHP interfaces are optional and unnecessary. ... before troll Tony Marston stuck his big mouth in here. ...
    (comp.lang.php)