Zend_Form and Liskov Substitution Principle
- by blockhead
A very common pattern I see (I'm picking on Zend Framework, only because I was dealing with it at the moment of this question), is something like this:
class My_Form extends Zend_Form {
public function init() {
$this->addElement();
}
}
Zend_Form is not an abstract class, but is perfectly usable on its own. This seems to be "recommended" as place to "encapsulate" your forms into a nice class.
Does this violate the Liskov Substitution Principle? Each subclass of Zend_Form will have a wildy different behavior than the base class. Would it be better to use composition for this, or am I totally misunderstanding this principle?