Hi! On 9/17/11 2:39 PM, Richard Quadling wrote:
An interface is the absolute here. Sub classes (the super class being abstract or otherwise), should be able to define MORE parameters (with or without default values). Otherwise they aren't extending, but implementing - and for me that's the role of an interface.
No, this is not correct. Requiring more parameters, despite seeming like "extending", is actually not extension but additional restriction - if you had function with 1 param, you could call it as foo(1) or foo(1,2) (in the second case 2 would be ignored) but if you add second parameter now only foo(1,2) works. The new method is more restrictive than the old one, and that shouldn't happen in proper OO.
It is only interfaces that guarantee things because the interface IS the guarantee. A class isn't beholden to anything it inherits. You can override methods, completely obscuring the super class if you so want.
This is a wrong thing to do and should be avoided at all costs. Or, putting it other way, if you want to do this, do not use inheritance, it's not for that. By using inheritance, you agree to a contract that says "this class is at least as good as the base class, but maybe also better". Violating this contract is setting yourself up for all kinds of trouble.
A subclass can completely divorce itself from the superclass.
It "can", technically, but it should not. Of course, we can not control it, except for most basic cases, but at least in basic cases we can.
Now, I have absolutely no idea where separate treatment of abstract and non-abstract classes came from - can anybody explain that (preferably people that actually implemented that)?
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php