> From: Fran Fabrizio [mailto:[EMAIL PROTECTED]]
> Sent: 12 June 2002 21:48
Nothing indepth, just a quick response, but it looks like your huge if
statement can be replaced using a hash. Maybe something like:
# just an eg, this data is static and can be required from
# your startup.pl so that all child get a shared copy
%global::dispatch = (
summary => { template => 'summary', actions => [ 'doSummary',
'doOther' ] },
doctor => { template => 'docact, actions => [ 'healthyself', ] },
)
# In your generic Controller / Handler
if ( exists $global::dispatch{$template} ) {
my $dispatch = $global::dispatch{$template};
my $tmpl = getTemplate( $despatch->{template} );
foreach my $function ( @{$dispatch->{actions} ) {
&$function($dbh,$tmpl);
}
print header . %tmpl->output();
} else {
unavailable();
}
The nice thing about this is you end up with a generic Controller, and
can separate the config off somewhere else. The Controller will probably
change much less than your config, so separation makes sense.
I don't really see an issue with the Controller being responsible for
returning the response, after all it fielded the request in the first
place. I would try hard to keep ALL HTML in the View world - whether you
create a View class or use a templating approach.
0.02c
Regards
Jeff