agreed.. cause that way you have a choice .. cause this gives you both options:
To call a parent constructor, if needed
Parent constructor do not gets called by default
But in case of java, i see no way u can ask proggie not to call Parent constructor if it exists in there.. Correct me if i am wrong ..
Okay you need a scenario, take mine.
I"m using my home-cooked MVC architecture and I keep building it.
Most of my pages have a few variables that I need to check for each single time. This is the "pageAction" variable. 99% of pages will have it.
I wanted to automatically get this pageAction from POST and put it in a var in the parent, that way the child controller does not have to do this everytime...hence automation.
If I have to call some constructor, or some function, I could just make it a rule and make sure each controller child class grabs the pageAction (They always have to if the page is not static)
For example here's a .php page that uses a customer controller (CT)
(I'm just typing this as i go and is not actual code)
[PHP]
//my includes
require_once("blah.php"); //etc...
$customerCT = new CustomerCT();
switch($customerCT->getPageAction())
{
case "Add":
$customerCT->add();
break;
case "Update":
$customerCT->update();
break;
}
$smrty->dispay("customer.tpl");
[/PHP]
That's an over-simplified version of my architecture. In the constructor of CustomerCT I get POST variables that are specific to that page. "pageAction" is very common, exists on all pages with a submit button.
How do other frameworks do it (Cake, Zend, Symphony).
In the global include, or index.php file, they just grab it and put it in a global variable?
I guess that's one way.
So I could do
[PHP]
switch(PAGE_ACTION)
{
case "Add" ....
[/PHP]
I guess that would work...yes? is it cleaner?
pbmods is good at ZendF, hopefully he can shed some light on this.
Thanks guys,
Dan