I have a question regarding the practices of using init. If I have a parent class with multiple child classes and they all have the same content inside their init functions would it be best to place that content in the parent init class and then simply do:
public function init(){
parent::init();
}
this would seem logical but every where I read, which is unfortunately zend specific, they say to leave the init method in the parent class empty to avoid complexity.
can some one clarify please?
Wait, what? If the parent class needs an
initmethod, and the children need the exact same method… just add it to the parent class and do nothing with the children, since they’ll inherit it automatically.This:
is much better written as:
(Yes, that’s nothing. If all the method does is call the parent method, just leave it out.)