Action-Domain-Response: A Tentative MVC Refinement

Posted by Unknown on Monday, May 5, 2014

(This post is an offering of a first draft, not a final version. I feel very much like I am slowly feeling my way toward something, rather than declaring a completed definition out-of-hand. It may end up being a dead end, or it may already exist in some form with which I am not familiar. Even so, I want to present it for thoughtful, considerate commentary.


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. For example, this pattern is partly revealed by how we generally do web routing and dispatch. 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.


Action-Domain-Response


Organizes a single interaction between a web client and a web application into three distinct roles.



Action ---> Response
||
Domain


Terms


Action (taken from <form action="...">) is the logic that connects the Domain and Response.


Domain is the domain logic. It manipulates the domain, session, application, and environment data, modifying state and persistence as needed.


Response is logic to build an HTTP response or response description. It deals with body content, templates and views, headers and cookies, status codes, and so on.


Narrative


Operational Description




  1. The web handler dispatches the incoming request to an Action.




  2. The Action interacts with the Domain and gets back Domain data.




  3. The Action feeds the Domain data to the Response logic, and then gives control to the Reponse.




  4. The web handler sends the response back to the client.




Compare and Contrast With MVC


The dominant pattern describing web interactions is Model-View-Controller. Is Action-Domain-Response really just Model-View-Controller in drag? We can see that the ADR terms map very neatly to MVC terms:



Model <--> Domain
View <--> Response
Controller <--> Action


The two seem very similar. How are they different?


Typically, the View does not consider response headers, only the response body. Also typically, a Controller has more than one action method in it, and managing the different preconditions for these action methods carries its own overhead.


Model vs Domain


I can think of no significant differences here, other than that the Response does not interact with the Domain in meaningful ways. The Response might use Domain objects like entities and collections, but only for presentation purposes; it does not modify the Domain or feed information back to the Domain as described under MVC.


Controller vs Action


In common usage, most Controller classes in an MVC architecture contain several methods corresponding to different actions. Because these differing action methods reside in the same Controller, the Controller ends up needing additional wrapper logic to deal with each method properly, such as pre- and p


Truncated by Planet PHP, read more at the original (another 19604 bytes)




more

{ 0 comments... » Action-Domain-Response: A Tentative MVC Refinement read them below or add one }

Post a Comment

Popular Posts