Jump to content

Action–domain–responder: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
mNo edit summary
tag as one source
 
(17 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{short description|Software architectural pattern}}
'''Action–domain–responder''' ('''ADR''') is an adaptation of [[Model–view–controller]] (MVC), a [[Architectural pattern|software architectural pattern]] that was proposed by Paul M Jones{{ref|https://github.com/pmjones/adr}} to be better suited for web applications. Similar to MVC, the application is divided into three parts.
{{Original research|date=February 2023}}
{{one source |date=March 2024}}
'''Action–domain–responder''' ('''ADR''') is a [[Architectural pattern|software architectural pattern]] that was proposed by Paul M. Jones<ref>{{cite web|url=http://paul-m-jones.com/archives/5970|title=Action-Domain-Responder: A Tentative MVC Refinement |website=paul-m-jones.com}}</ref> as a refinement of [[Model–view–controller]] (MVC) that is better suited for web applications. ADR was devised to match the request-response flow of [[HTTP]] communications more closely than MVC, which was originally designed for desktop software applications. Similar to MVC, the pattern is divided into three parts.


== Components ==
== Components ==
* The ''action'' part can closely match http requests (URLs and their methods).
* The ''action'' takes HTTP requests ([[URL]]s and their methods) and uses that input to interact with the ''domain'', after which it passes the domain's output to one and only one ''responder''.
* The ''domain'' part relates to the subjects of the application.
* The ''domain'' can modify state, interacting with storage and/or manipulating data as needed. It contains the business logic.
* The ''responder'' part relates to providing the output from the application.
* The ''responder'' builds the entire HTTP response from the ''domain''<nowiki/>'s output which is given to it by the ''action''.


== ADR versus MVC ==
== Comparison to MVC ==
ADR should not be mistaken for a renaming of MVC.
ADR should not be mistaken for a renaming of MVC; however, some similarities do exist.
*The MVC ''model'' is very similar to the ADR ''domain''. The difference is in behavior: in MVC, the ''view'' can send information to or modify the ''model'',{{Citation needed|date=February 2021}} whereas in ADR, the ''domain'' only receives information from the ''action'', not the ''responder''.
* In web-centric MVC, the ''view'' is merely used by the ''controller'' to generate the content of a response, which the ''controller'' could then manipulate before sending as output. In ADR, execution control passes to the ''responder'' after the ''action'' finishes interacting with the ''domain'', and thus the ''responder'' is entirely responsible for generating all output. The ''responder'' can then use any view or template system that it needs to.
* MVC ''controller''s usually contain several methods that, when combined in a single class, require additional logic to handle properly, like pre- and post-action hooks. Each ADR action, however, is represented by separate classes or closures. In terms of behavior, the ''action'' interacts with the ''domain'' in the same way that the MVC ''controller'' interacts with the ''model'', except that the ''action'' does not then interact with a view or template system, but rather passes control to the ''responder'' which handles that.

== References ==
{{reflist}}

==External links==
* [http://paul-m-jones.com/archives/5970 Paul M. Jones' original proposal of ADR]
* [http://martinbean.co.uk/blog/2016/10/20/implementing-adr-in-laravel/ Implementing ADR in Laravel], an implementation of the pattern in the [[Laravel]] [[PHP]] [[Web framework|framework]].

{{Design Patterns patterns}}

{{DEFAULTSORT:Action-domain-responder}}
[[Category:Software design patterns]]
[[Category:Architectural pattern (computer science)]]


{{Compu-prog-stub}}

Latest revision as of 21:30, 26 March 2024

Action–domain–responder (ADR) is a software architectural pattern that was proposed by Paul M. Jones[1] as a refinement of Model–view–controller (MVC) that is better suited for web applications. ADR was devised to match the request-response flow of HTTP communications more closely than MVC, which was originally designed for desktop software applications. Similar to MVC, the pattern is divided into three parts.

Components

[edit]
  • The action takes HTTP requests (URLs and their methods) and uses that input to interact with the domain, after which it passes the domain's output to one and only one responder.
  • The domain can modify state, interacting with storage and/or manipulating data as needed. It contains the business logic.
  • The responder builds the entire HTTP response from the domain's output which is given to it by the action.

Comparison to MVC

[edit]

ADR should not be mistaken for a renaming of MVC; however, some similarities do exist.

  • The MVC model is very similar to the ADR domain. The difference is in behavior: in MVC, the view can send information to or modify the model,[citation needed] whereas in ADR, the domain only receives information from the action, not the responder.
  • In web-centric MVC, the view is merely used by the controller to generate the content of a response, which the controller could then manipulate before sending as output. In ADR, execution control passes to the responder after the action finishes interacting with the domain, and thus the responder is entirely responsible for generating all output. The responder can then use any view or template system that it needs to.
  • MVC controllers usually contain several methods that, when combined in a single class, require additional logic to handle properly, like pre- and post-action hooks. Each ADR action, however, is represented by separate classes or closures. In terms of behavior, the action interacts with the domain in the same way that the MVC controller interacts with the model, except that the action does not then interact with a view or template system, but rather passes control to the responder which handles that.

References

[edit]
  1. ^ "Action-Domain-Responder: A Tentative MVC Refinement". paul-m-jones.com.
[edit]