|
(You are
Anonymous)
|
Suggestions for simple and effective run mode namesIt helps, as your application grows, to use meaningful names for run modes. When your application gets large it is hard to remember what 'mode34' does. sub setup {
my $self = shift;
$self->start_mode( 'home' );
$self->run_modes(
'home' => 'show_home',
'services' => 'show_services',
'news' => 'show_news',
'calendar' => 'show_calendar',
);
# keep templates out of document root
$self->tmpl_path('./tmpl');
}
When developing projects using forms, you have run modes to display the form and run modes to process it. One organization tool is to give related run modes a common prefix. This can be the name of the entity being worked with. Then different verb endings can convey the action. Here's an example that uses CGI::App's syntax to create a list of run modes that map directly to routine names. Space is also used to seperate related routines. $self->run_modes([qw/
item_add_form
item_add_process
item_edit_form
item_edit_process
item_delete
/]);
Even easier: CGI::Application::Plugin::AutoRunmodeLook into CGI::Application::Plugin::AutoRunmode for a way to skip this step completely and declare your run modes like this instead: sub item_add_process : Runmode { ... }
|