views:

66

answers:

3

I didn't find any info on searches when I looked this up. I've been doing a lot of research on design patterns but I haven't seen anything as far as routing goes. What I mean is this: back in my php days I would write code on one page and then pass it to the next. That created (though I wasn't aware of it at the time) tightly coupled code where changing the routing required I muddle through a long chain of pages.

I was wondering if there was any specific pattern or class of patterns that deal with sending our form data back to a central object and having that call the next form. So for example I would pass back to a routing.php rather than signUpPage2.php. Then routing.php would passs the data to signUpPage2.php.

I know this is what PHP Cake and RoR try to do but I am specifically wondering if there is a pattern for this. This doesn't seem to just be MVC I don't thing but I could be wrong.

Thanks!

Edit, does anyone have any book recommendation for these types of patterns? Thanks

A: 

This sounds like Apache Struts whereby you specify transitions depending on the outcome of actions.

Must admit that I don't know what the pattern name is called.

Tom Duckering
+1  A: 

Post/Get/Response

http://en.wikipedia.org/wiki/Post/Redirect/Get

Quoted:

When a web form is submitted to a server through an HTTP POST request, a web user that attempts to refresh the server response in certain user agents can cause the contents of the original HTTP POST request to be resubmitted, possibly causing undesired results, such as a duplicate web purchase.

To avoid this problem, many web developers use the PRG pattern — instead of returning a web page directly, the POST operation returns a redirection command (using the HTTP 303 response code [sometimes 302] together with the HTTP "Location" response header), instructing the browser to load a different page using an HTTP GET request. A web user can then safely refresh the server response without causing the initial HTTP POST request to be resubmitted.

jfar
+1  A: 

You have pages (View) which also decide on routing (Control). At the simplest level we pull the control logic out, separating View from Control - hence the popularity of Model View Controller in web apps.

The next step is to implement the Controller using some form of dispatch table - in the Java world that's done with frameworks such as Struts and JSF.

djna