(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:

###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 # }
versus
###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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.