I'm not sure how much cleaner the code would end up if you used polymorphism. I'm probably sceptic because of some experiences using Java Struts, where we ended up with an enormous class hierarchy trying to get at least *some* code reuse in the different actions (in Struts an Action is an object roughly equivalent to a
run_mode in CGI::Application).
It's been noticed before that inheritance is often not the best way to handle code reuse, but Java and Struts don't give you much choice (if you want a reasonably simple API). In any case, spreading your code out over many classes that are all somehow related, even disregarding code reuse issues, makes the code hard to understand and adapt IMHO.
I can see some potential in using Class::Prototyped (and hence, CGI::Prototype) in that regard, but I would have to try it "in the wild" to see if it really holds up.
Right now, I like the fact that you can just group a bunch of related runmodes into one CGI::Application subclass: it makes their relationship explicit and you can make a shared base class to for bigger applications if you need that.
updated: fixed typo
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||