Results 1 to 16 of 16
Nov 19, 2004, 14:20 #1
- Join Date
- May 2001
- 0 Post(s)
- 0 Thread(s)
Interface Vs. Abstract and Inheritance
In an attempt to understand interfaces, and abstract classes I downloaded creole and checked out their use of them.
I am confused!
I took a look at the interface, abstract, and derived classes for a Prepared Statement.
PreparedStatementCommon.php which is the abstract class contains about 28 methods of which only 1 is declared as abstract escape($str)
PreparedStatement.php is the interface class which declares 27 of the methods implemented in the abstract class.
MySQLPreparedStatement.php is a derived class which extends the abstract which implements the interface and implements the method escape().
My question is why bother with the abstract class in this example, why not just add the 1 abstract method to the interface, and make PreparedStatementCommon.php into a regular class.
Im having trouble seeing the value of the abstract class here.
Thanks for any input
Also, I was reading a another post and there was a link to an article talking about "Why extends is evil", sorry can't remember the thread. But the jist of it was don't use inheritance or avoid it at all costs, and opt for Interfaces instead. I don't understand, how do you acheive what extends gives you using an interface, since you can't implement anything in the interface. There was a quote saying somethng to the affect, "80 percent of your code should be wriiten in terms of interfaces...".