Action–domain–responder (ADR) is a
software architectural pattern that was proposed by Paul M. Jones
as a refinement of
Model–view–controller
Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
(MVC) that is better suited for web applications. ADR was devised to match the request-response flow of
HTTP
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
communications more closely than MVC, which was originally designed for desktop software applications. Similar to MVC, the pattern is divided into three parts.
Components
* The ''action'' takes HTTP requests (
URL
A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifie ...
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'' 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
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'', 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
External links
Paul M. Jones' original proposal of ADRImplementing ADR in Laravel an implementation of the pattern in the
Laravel
Laravel is a free and open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern and based on Symfony. Some of the features ...
PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group ...
framework
A framework is a generic term commonly referring to an essential supporting structure which other things are built on top of.
Framework may refer to:
Computing
* Application framework, used to implement the structure of an application for an op ...
.
Software design patterns
Architectural pattern (computer science)
{{Compu-prog-stub