I've only just started playing with CGI::Application so my view may be a little immature in that sense.

I see it as providing a means of presenting views to the user in a nice encapsulated way but allowing pre and post processing on each view (or run mode).

With that in mind, I don't see each run mode as needing to be linear as that requires state management. If you want it to be linear - use state management and encode your path into your run modes. You would want to encode the previous run mode into the session so when you hit the new run mode (or view in my terminology) you can check if you have come from the right place.

Whether you do that in the prerun method or inside the run mode method is upto you. How you encode the session is also upto you. If its just tracking where you have been then something in the URL could be a nice way of doing it as it avoids cookies (but thats a topic for a different node?).

In answer to your direct question, each page view on the screen is a view into your application (or run mode). One view, one run mode, one function. The only place I would stay within a run mode is if the user didn't fill something in properly. I'd then redisplay with an error message. But thats me :).

I wouldn't worry about having a large number of run modes. Frankly it should be proportional (roughly) to the number of facilities you offer to your user. So if they register, login and logout then that would be 2+2+1. Register form mode, thanks for registering mode, login form mode, thanks for logging in mode redirect page (you could make this generic) and a logout mode (you don't need a confirmation screen for this!). Of course that's just off the top of my head.

HTH

SP

In reply to Re: CGI::Application, have I made a big mistake. by simon.proctor
in thread CGI::Application, have I made a big mistake. by jdtoronto

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.