[cgiapp] handling data and control flow better (longish)

David N. Blank-Edelman dnb at ccs.neu.edu
Mon Jun 8 10:23:49 EDT 2009


Hi Ron-
   Thanks so much for writing. I always appreciate seeing other  
people's code. I have to admit that I'm a bit puzzled as to how my  
questions and your answers mesh. I'm sure this is just my lack of  
understanding. Let me see if I can repeat back your answer in a  
different way so you can see where the disconnect lies.

To the question of how to deal with several sets of data context (CGI  
query, stuff stored in a session, etc), you seemed to reply "REST". I  
thought I had a pretty decent handle of REST interfaces, but I don't  
see how they come into play for me in this case. In my case I'm not  
necessarily operating on specific objects like you were (contacts in  
an address book). I think of rest as coming into play when one wants  
to interact with objects like contacts, usually in a more random  
access way.  That differs from my mental model for my app in that I  
see mine as more of moving through a sequence of cumulative steps (/ 
pages). Even if I were to think of it as moving around in a state  
machine, I still can't conceive of how I would shoehorn it into a REST  
frame of mind (the S in REST nonwithstanding). But even if I could,  
how does this model reduce the multiple sets of data problem?

[Aside #1: I did look at using C::A::P::Stash, ala Catalyst, but it  
didn't seem like it would help much]

To the question of "how do I deal with the complex control flow/data  
handling introduced by validation", part of the answer seems to be to  
use Data::FormValidator vs. C::A::P::ValidateRM. You seem to avoid the  
"run_mode_1 leads to run_mode_2 leads to run_mode_3, oh wait, I have  
to go back to run_mode_2 because the input run_mode_3 got wasn't  
valid" control flow.

But I'm not clear how much of that avoidance comes from your  
application not needing to backtrack with all previous state intact if  
something goes wrong. Can I check if I understand something vis a vis  
your recovery from error? I see you constructing an error-full  
template to return from report_add, but I don't understand how that  
gets the user back to add_note in such a fashion that they could  
correct their mistake and continue on from there. Are you basically  
resetting your notion of state at that point, such that when the user  
comes back into add_note from the error'd template he or she does so  
with no previous state saved? In my example, where I'm moving from  
cumulative step to step I'm not clear I could do the same.

      -- dNb




More information about the cgiapp mailing list