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

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

 



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@xxxxxxxxxxxxxxx		facilmejor@xxxxxxxxx

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