Zend_Form and Liskov Substitution Principle
Posted
by blockhead
on Stack Overflow
See other posts from Stack Overflow
or by blockhead
Published on 2009-05-21T20:09:57Z
Indexed on
2010/05/21
23:20 UTC
Read the original article
Hit count: 250
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?
© Stack Overflow or respective owner