What is the difference between DAL, DTO and DAO in a 3 tier architecture style including with MVC

后端 未结 2 1816
名媛妹妹
名媛妹妹 2021-02-01 20:06

Recently I was learning about ORM (Object Relational Mapping) and the 3 tier architecture style (presentation,business and data persistence). If I understand c

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 21:10

    You might wanna first distinguish between the MVC pattern and the 3-tier architecture. To sum up:

    3-tier architecture:

    • data: persisted data;
    • service: logical part of the application;
    • presentation: hmi, webservice...

    Now, for the above 3-tier architecture, the MVC pattern takes place in the presentation tier of it (for a webapp):

    • data: ...;
    • service: ...;
    • presentation:
      • controller: intercepts the HTTP request and returns the HTTP response;
      • model: stores data to be displayed/treated;
      • view: organises output/display.

    Life Cycle of a typical HTTP request:

    1. The user sends the HTTP request;
    2. The controller intercepts it;
    3. The controller calls the appropriate service;
    4. The service calls the appropriate dao, which returns some persisted data (for example);
    5. The service treats the data, and returns data to the controller;
    6. The controller stores the data in the appropriate model and calls the appropriate view;
    7. The view get instantiated with the model's data, and get returned as the HTTP response.

提交回复
热议问题