Re: What is the practical use of "abstract" and "interface"?
| From: | Iñigo Medina García | Date: | Tue, 15 Apr 2008 06:47:13 +0000 |
| Subject: | Re: What is the practical use of "abstract" and "interface"? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272998@lists.php.net to get a copy of this message | ||
Daevid Vincent wrote:
> I've had at least three job interviews in the past two weeks, and each one has asked me
> this rather "text book academic" question regarding the difference between
> "abstract" vs. "interface". I've been coding for nearly 20 years, and at
> least 10 of those have been in PHP and another 3 in J++. I have NEVER used either of these
> concepts/keywords? Am I missing some exciting tool/feature?
>
> All the reading I've done tonight just reinforces my thoughts that these are, for the most
> part useless. Unless you're building some HUGE project that has an API and there are teams of
> people that are going to extend your framework, then what good are they?
>
> This DB wrapper is the closest to an answer I've come across.
>
> http://www.developer.com/lang/php/article.php/3604111
>
> But that still doesn't explain the difference between abstract and interface, it only
> illustrates the possible need for a 'template' so others know which methods they must
> implement. In my mind, it just seems like overhead, as if you were going to write another DB wrapper
> using this one, then wouldn't you just look at their code (example) and implement those same
> methods anyways? I mean, you'd have to look at the abstract/interface to find out the required
> methods, so why not skip that and just look at the actual class instead?
>
> Here are two more pages that still don't seem to answer why there are both and when
> you'd use one over the other?
>
>
> http://www.hiteshagrawal.com/php/oops-in-php5/oops-in-php5-tutorial-abstract-class
>
> http://www.hiteshagrawal.com/php/oops-in-php5/oops-in-php5-using-interface
>
> And then this completely absurd over the top use of them for a HelloWorld example, which seems
> to use them just for the sake of using them...
>
> http://marc.info/?l=php-general&m=115950654928311&w=2
>
> Lastly was this page:
>
>
> http://www.phpro.org/tutorials/Object-Oriented-Programming-with-PHP.html
>
> Which seems to only really provide a "hack" (printerFax) to circumvent the lack of
> multiple inheritance.
>
>
> Can someone clear this up for me?
Look at this url:
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
Iñigo
> Daevid.
> http://daevid.com
>
>
--
--------
Iñigo Medina García
Librería Díaz de Santos Madrid (Spain)
imedina@diazdesantos.es facilmejor@gmail.com