Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the difference between an MVC Model object, a domain object and a DTO
    text
    copied!<p>What is the difference between a MVC Model object, a domain object and a DTO?</p> <p>My understanding is:</p> <p>MVC Model object:</p> <p>Models the data to be displayed by a corresponding view. As such may not map directly on to a domain object, i.e. may include data from one or more domain objects.</p> <ol> <li>Client side</li> <li>May contain business logic, e.g. validation, calculated properties, etc</li> <li>No persistence related methods</li> </ol> <p>Domain object:</p> <p>Object that models a real world object in the problem domain like Reservation, Customer, ORder, etc. Used to persists data.</p> <ol> <li>Server side</li> <li>No business logic</li> </ol> <p>DTO (Data Transfer Object):</p> <p>An object used to transfer data between layers when the layers are in separate processes, e.g. from a DB to a client app. Allows a single transaction across the wire rather than multiple calls. A DTO contains just data and accessor methods, no logic. The data is for a particular DB transaction so may not may directly on to a domain object, i.e. may include data from one or more domain objects.</p> <ol> <li>Used on both sides as passed between layers</li> <li>No business logic</li> <li>No persistence related methods</li> </ol> <p>So to the questions:</p> <p>(1) Is my understanding correct? Am I missing some key points?</p> <p>(2) Are there any reasons not to use Domain objects as the MVC Model assuming that the Model objects do not require extra business logic?</p> <p>(3) Are there any reasons not to use DTOs as the MVC Model assuming that the Model objects do not require extra business logic?</p> <p>Thanks.</p> <p>Tim</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload