Re: What is the practical use of "abstract" and "interface"?

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

 



On 16/04/2008, Tony Marston <tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
>  > -----Original Message-----
>  > From: Robin Vickery [mailto:robinv@xxxxxxxxx]
>  > Sent: 16 April 2008 17:23
>  > To: Jay Blanchard
>  > Cc: Tony Marston; php-general@xxxxxxxxxxxxx
>  > Subject: Re:  What is the practical use of "abstract"
>  > and "interface"?
>  >
>  >
>  > On 16/04/2008, Jay Blanchard <jblanchard@xxxxxxxxxx> wrote:
>  > > [snip]
>  > >  > What about encapsulation?
>  > >
>  > >  Interfaces have nothing to do with encapsulation for the
>  > smple reason
>  > > that I  can have encapsulation without using interfaces.
>  >
>  > Unique use of logic there.
>  >
>  > By similar reasoning; swimming trunks have nothing to do with
>  > swimming for the simple reason that I can swim without trunks.
>
>
> Correct. Encapsulation and polymorphism can be achieved without interfaces,
>  therefore interfaces are not necessary.

You've switched positions from "have nothing to do with" to "not
necessary". Prefacing your statement with "Correct" makes it appear
that you're merely re-affirming your original position.

>  There is nothing I can achieve with interfaces that I cannot achieve without
>  them, therefore they are not necessary. Not only are they not necessary,
>  because they do not add value they are totally useless.

There's nothing that you can achieve with PHP5 that you can't achieve
with PHP/FI either. Maybe it's time to scrap all this needless
complexity and return to our roots.

I've already given an example of how formally defined interfaces add
value and you chose to dismiss it on the grounds that there's no need
to check interfaces if you don't use interfaces. *Every* modular
system uses interfaces whether they're formally defined or not.

>  Some people seem to use them simply because they are there, or that
>  was how they were taught.

Some people don't use them because they weren't there when they
learnt, or they weren't taught how. What's your point?

>  > > You are still missing the fundamental point. There is absolutely
>  > > nothing I can do WITH interfaces that I cannot do WITHOUT them,
>  > > therefore they are redundant.
>  >
>  > How about compile-time checking that the interface has been
>  > correctly implemented?
>
>
> If you don't use interfaces there is no need for such checking.

ok, s/interface/api/ if that makes you happier.

If you need a concrete example, lets say your app has a nifty
plugin system so third-parties can extend it. You have an API for
plugins to register themselves, and each plugin exposes a set of
methods that your application calls when necessary.

If you define an 'interface' for your API and each plugin implements
that interface, then if there's a plugin that doesn't implement it
properly you'll know as soon as the plugin loads.

If you don't formally define the interface, you're not going to know
that the plugin's wrong until the badly implemented method gets
called. And even then it might just introduce a hard to diagnose bug
rather than an obvious failure.

-robin

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