http://www.perlmonks.org?node_id=157582

impossiblerobot has asked for the wisdom of the Perl Monks concerning the following question:

I'm about to start writing a medium-sized web-based application, which may eventually become much more complex. Although I am quite capable of coding the entire thing from scratch, using the appropriate modules for standard tasks, I thought I might be able to save myself some work, increase maintainability, and better prepare myself for growth by using one of the several CGI frameworks available.

Even after looking at the various nodes comparing/recommending various frameworks (such as Web Application Frameworks and their Templating Engines with a Comparative Study of Template and HTML::Template) and skimming the docs for several of the options mentioned, I have not reached that state of inner peace that is required before I commit to an undertaking. So I thought some more feedback/discussion might help. (Not to mention the fact that the tools available change so quickly that older posts may no longer reflect current reality.)

I hope that not everything that the monks have to say on this matter has been said. So what follows is a combination of the specifications for what I need to accomplish and some exposition about how I would normally do these things. I hope this doesn't get too long:

The Basics:

Since I'm not sure on which servers I will be deploying this, I can't count on having access to mod_perl; so my choices are limited to those frameworks that will work under CGI.

I don't necessarily need an all-in-one solution, but if I have to piece together too much of it myself, I don't know that I'm really doing myself any favors by choosing a framework solution (though I suppose extending an existing solution would be the monk-ish way to solve that problem). :-)

The Details:

Here are some of the functions I will need, along with My Thoughts or How I Would Probably Do It Myself. These are not absolute rules; I am willing to consider alternative theories, but these notes do reflect some of my current preferences:

View Management:

Doing It Myself, I would probably just use a dispatch table for the various 'screens' or 'views' the application would be presenting, abstracting as much of the re-usable logic as is useful into a separate module.

Session Management:

I would probably use Apache::Session, and use cookies for storing the session ID, with URL-munging as a fallback.

CGI Form-handling:

I would probably parse form data with CGI.pm (just because it would already be installed), even though one of the stripped-down versions (such as CGI::Lite) would probably be a better fit (since I don't use CGI.pm's HTML -generation routines).

Form Validation:

Although I could use a module for this, if I were Doing It Myself, I would probably use JavaScript on the client side (for immediate feedback) and stricter validation/taint-checking on the server side using regexes, etc.

Templating:

I haven't committed to any particular template module at this point.

I normally work with a designer, and in the past I've usually followed these rule for templates:

  • Use a one-template system -- I don't want me, or the designer, to have to build half-a-dozen templates everytime the site design changes.
  • Template mark-up should be visible in Dreamweaver's WYSIWYG mode -- The designer can see the mark-up, and know not to remove it. Or the designer can even add simple tags to the appropriate place(s) in the template, without having to delve into the HTML.
  • The design goes in the template; the logic goes in the application -- Otherwise the purposes other two rules will probably be defeated. (Having some presentation logic in the template might be useful, but I'm not sure how well it would work with my "one-template" plan.)

    So typically I've used a template that replaced the <TITLE> tag and filled in a content area with the results of each page. The designer used CSS to modify the look of the various elements in the content area.

Potential Requirements:

  • Authentication -- I will probably, at some point, need to authenticate some sessions with a username/password.
  • DBI -- I will definitely be using DBI (with MySQL) for this project, so I suppose that any framework database integration might be useful (though not strictly necessary).
  • Others -- I'm sure there are some things I should have mentioned, but forgot to.

The Request:

I'm hoping that our hallowed monks will be able to help me determine what the best CGI application building tools are for me. Feel free to tell me where my thinking has gone wrong, what I should do instead, as well as how you have or would do it yourself. If you've integrated these features using one or more packages, please share your experiences and opinions. Hopefully this will be as useful to others as I expect it will to me.


Impossible Robot