RE: [PHP] What is the practical use of "abstract" and "interface"?
| From: | Jay Blanchard | Date: | Wed, 16 Apr 2008 12:53:54 +0000 |
| Subject: | RE: [PHP] What is the practical use of "abstract" and "interface"? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273042@lists.php.net to get a copy of this message | ||
[snip]
"enforcing a contract" is a lot of maningless gobbledegook. The simple
fact
is that it is possible to have an interface without ever using the term
"interface". Nothing extra is added by using the term "interface"
(except
for effort) so there is absolutely no advantage in doing so. That is why
I
say that the term "interface" is a waste of effort as absolutely nothng
is
gained.
[/snip]
What about encapsulation? Also, there is an advantage to interfaces that
has not been mentioned yet, the fact that a class can implement multiple
interfaces (polymorphism). And yes, I know that I can extend by
inheritance to create polymorphism too, but what is the most efficient
method? It depends on the application.
Like anything else interfaces are a tool and there may be multiple tools
that can accomplish the same job (i.e. table saw, band saw, hand saw).
Pick the one that is right for you.