Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones:
Action-Domain-Response: A Tentative MVC Refinement
May 07, 2014 @ 14:49:36

In his latest post Paul Jones has proposed a "tentative MVC refinement" as the structure behind your application. He suggests something called the action-domain-response pattern, focusing on some of the more common practices in web application development today instead of an ideal.

The term MVC has experienced some semantic diffusion from its original meaning, especially in a web context. Because of this diffusion, the Action-Domain-Response pattern description is intended as a web-specific refinement of the MVC pattern. I think ADR more closely fits what we actually do in web development on a daily basis. [...] We generally route and dispatch not to a controller class per se, but to a particular action method within a controller class. It is also partly revealed by the fact that we commonly think of the template as the View, when in a web context it may be more accurate to say that the HTTP response is the View. As such, I think ADR may represent a better separation of concerns than MVC does in a web context.

He goes through the structure he's worked up, showing the interaction between the parts and compares the flow to a typical MVC-based application. He also mentions a few other MVC pattern alternatives including Data-Context-Interaction and Model-View-ViewModel. He then gets into an actual code-based example using a typical blog application. He compares the directory structure and proposes that instead of one controller per file it becomes one action per file (and one response per file accordingly).

tagged: modelviewcontroller mvc actiondomainresponse adr designpattern application

Link: http://paul-m-jones.com/archives/5970


Trending Topics: