Action Domain Responder (ADR) design pattern

The Action Domain Responder pattern is a software architectural pattern that aims to provide a clear separation of concerns in web application development.

The ADR pattern typically consists of three main components:

  1. Action: The Action component handles the initial input and interaction with the external world, such as handling HTTP requests in web applications. It is responsible for receiving the request, validating input data, and invoking the appropriate Domain component to perform the necessary business logic.
  2. Domain: The Domain component contains the core business logic and rules of the application. It represents the problem domain and encapsulates the entities, business rules, and operations related to the application's specific domain. The Domain component is responsible for performing any necessary computations, validations, or modifications to the data.
  3. Responder: The Responder component is responsible for generating the response to be sent back to the client or external system. It formats the output of the Domain component and prepares the appropriate response, such as an HTTP response in a web application context.

The ADR pattern promotes separation of concerns and modularity in web application development. It allows for a clear distinction between the handling of input/output, business logic, and response generation, making the codebase more maintainable and testable. Additionally, it enables reusability of the Domain component across different interfaces or presentation layers, such as web, CLI, or APIs.

It's worth mentioning that the ADR pattern is similar to other patterns such as Model-View-Controller (MVC) or Model-View-Presenter (MVP), but with some differences in terms of component responsibilities and the level of separation achieved.

While both the Action Domain Responder (ADR) pattern and the Model-View-Controller (MVC) pattern are architectural patterns used in web application development, they have some differences in terms of component responsibilities and the level of separation achieved. Here are the key differences between ADR and MVC:

  1. Component Responsibilities:
    • MVC: In MVC, the Model represents the data and business logic, the View is responsible for rendering the user interface, and the Controller handles the user input and orchestrates the flow between the Model and the View.
    • ADR: ADR separates the concerns even further. The Action component is responsible for handling the initial input and interaction with the external world, the Domain component encapsulates the core business logic, and the Responder component generates the response.
  2. Level of Separation:
    • MVC: MVC provides a moderate level of separation between the Model, View, and Controller components. While the Model and View have a clear separation, the Controller often needs to interact with both the Model and the View.
    • ADR: ADR aims for a higher level of separation. The Action component primarily focuses on handling input and invoking the Domain component, which contains all the business logic. The Responder component solely handles the response generation. This stricter separation helps to maintain a clearer boundary between the different responsibilities.
  3. Dependency Flow:
    • MVC: In MVC, the flow of dependencies typically goes from the Controller to the Model and View. The Controller controls the flow and communicates with the Model to retrieve or update data and with the View to render the output.
    • ADR: In ADR, the flow of dependencies primarily goes from the Action to the Domain component. The Action component receives the request, validates input, and invokes the appropriate Domain component. The Domain component performs the business logic and can communicate back to the Action for further processing or obtain necessary data.

Overall, ADR can be seen as an evolution of the MVC pattern, providing a higher level of separation and encapsulation. ADR's explicit separation of concerns makes it easier to understand, test, and maintain code by enforcing clear boundaries and responsibilities for each component. However, the choice between ADR and MVC depends on the specific requirements and complexity of the application being developed.

Similar Articles

Card image

The SOLID Principles

Card image

MVVM (Model View ViewModel) Architecture Pattern in Android

Card image

MVC architecture