Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Model-View-Controller: Template Toolkit vs. XSLT

by weierophinney (Pilgrim)
on Oct 15, 2004 at 18:33 UTC ( [id://399608]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Model-View-Controller: Template Toolkit vs. XSLT
in thread Model-View-Controller: Template Toolkit vs. XSLT

CGI::Application does many other things than "a giant if/elsif/else statement" -- and it doesn't even really do that. (It implements a hash-based dispatch table that maps a query string to a method; if no match is found, it uses a default as specified.)

What does CGI::Application do?

  • It provides a framework for developing re-usable, customizable application classes. Simply use the class, pass some metadata (in the form of a hash) to the constructor, and run() it
  • It provides a sane framework for developing applications; each screen gets a run mode, and each run mode gets a method -- CGI::Application-based classes are incredibly consistent and easy to debug because it's easy to determine what piece of code is executed when (look at the dispatch table instead of trying to scan through "a giant if/elsif/else statement").
  • It provides a means for wrapping a number of applications under a site-umbrella, through it's various cgiapp_*() hook methods. Using these, you can create a superclass that does security checks, places final application content in a sitewide template, and creates customized navigation and sidebars -- but still retain the flexibility of developing only a single application suite at a time.
If used correctly, CGI::Application can be used as a very good Controller for an MVC setup -- have it simply do the work of validating and sanitizing input, passing it to the Model, and piping the Model's return values to the View (a templating system).

What I like most about it is that, at it's core, it's a very slim piece of code that simply stays the heck out of my way as I build my applications -- no extraneous doodads or geegaws are loaded unless I specifically do so myself.

Yes, it's another dependency, but it has very little overhead and benefits that outweigh the dependency a thousandfold.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://399608]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-19 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found