I just wanted to comment on Number 3, here. Scroll down ;-)
kyle dawkins wrote: > > Fran (et al) > > I've stayed out of the MVC chitchat for a long time (very interesting > thread) because it's such a deep topic. But seeing as how Fran has > some concrete questions... > > > 3. How do you prevent a Controller from just becoming another big if > > statement, or is this their purpose in life? > > See Jeff's previous mail. Your structure is crying out for a dispatch > table; Jeff suggests building this out of a hash that defines what > actions to perform based on what your query values are. That's a great > place to start. GET RID OF YOUR BIG "IF" STATEMENT ASAP. > If I read this right, then it's something I am already doing and I'll throw it in here to show: ## My idea of a dispatch table! my %actions = ( 'view' => 'FES::Control::View', 'logout' => 'FES::Control::Logout', 'edit' => 'FES::Control::Edit', 'notes' => 'FES::Control::Notes', 'save' => 'FES::Control::Save', 'calendar' => 'FES::Util::Calendar', ); sub handler { my $r = Apache::Request->new(shift); ## BEGIN ignore (DECLINE) image requests and allow regular apache to handle them. return DECLINED if $r->content_type =~ /image/; ## END ignore image requests my $act = $r->param('act') || 'view'; if (my $h = $actions{$act}) { $r->push_handlers(PerlHandler => $h); $r->handler('perl-script'); return DECLINED; } else { my $stmt = "There is no such action as \'" . $act . "\'\n"; $r->pnotes('error', $stmt); $r->push_handlers(PerlHandler => 'FES::Error::Error'); $r->handler('perl-script'); return DONE; } ## end else [ if (my $h = $actions{$act... } 1; That's how I impliment at least _part_ of my controller without resorting to huge IF statements. Is this what was meant guys? --Jon R. If this is overly simplistic, or not what you meant, feel free to smack me around.