(Sorry for English)
Hi, currently I'm making an web application using only CGI module
And I'm not using frameworks like Catalyst,Dancer.. because I love DIY.
But programming with MVC pattern I have some trouble.
1. refine data and pass to the function vs pass raw data to the function and function refines the data
for example :
search_by_tags(split ',', $cgi->param('tags'));
versus
search_by_tags($cgi->param('tags')); # split called inside this functi +on
2. I have two controller classes Controller::Admin and Controller::Auth and there is one bootstrap file index.pl
I wonder which is better design :
Each Controller class calls $self->get_view()->print_blabla() as a result and that method prints a piece of HTML
versus
Controller returns a piece of HTML and bootstrapping script index.pl prints it.
for example:
versus###index.pl use Controller::Admin; Controller::Admin->new()->run(); ###Controller/Admin.pm sub run(){ my $auth = Controller::Auth->new(); $auth->loggedin() or $auth->require_login(); return; # that prints + login page # #Do some tasks if the user has logged in # }
###index.pl use Controller::Admin; print Controller::Admin->new()->run(); ###Controller/Admin.pm sub run(){ my $auth = Controller::Auth->new(); $auth->loggedin() or return $auth->require_login(); # that RETURNS + login page # #Do some tasks if the user has logged in # }
In reply to Which is better software design by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |