Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Relations between layers</h2> <p>If I understand your design well, the business layer does not know of (=does not use) the data layer, and the facade actually interconnects them by translating DAOs into DTOs and vice-versa.</p> <p>You should consider a rather different approach: Define interfaces for all data-related objects (regardless if DAOs or DTOs) and use an Inversion-of-Control container to weave the business layer and data access layer together. The reason is that in your design you might quickly run into the inability to retrieve additional data in right in the business layer. You'd end up with the facade substituting this lack and hence doing too much actual business logic.</p> <p>In case you make a clear connection between the business layer and the underlying data layer, while separating them with well-designed interfaces and an IoC container, you prevent this problem while maintaining good and concise internal design.</p> <h2>Usage of DTOs</h2> <p>I think it's alright that you have to pass the DTOs back to the back-end of your app. In your case the purpose of DTOs is (1) to supply information for the presentation layer, and (2) to provide a way of passing modified or new data to the back-end for further processing. DTOs for cases (1) and (2) need not be the same. Hence if it makes sense, you can pass to the back-end just a DTO representing a subset of the whole information.</p> <p>However, the back-end shall return a <em>new</em> DTO after processing, which, again, needs not to be the same DTO as the input DTO. This way the presentation layer can easily adapt to changes made by the back-end into related parts of the whole object.</p> <p>Imagine a simple Get / Update API such as this one:</p> <pre><code>CustomerDTO GetCustomer(int customerID); CustomerDTO UpdateCustomerAddress(int customerID, AddressDTO address); CustomerDTO UpdateCustomerPrimaryContact(int customerID, PersonDTO primaryContact); </code></pre> <p>You are using an ID to identify a customer and passing <em>in</em> a DTO that represents a subset of the customer record to be updated (regardless of the underlying data architecture). The <em>out</em> DTO represents the customer as a whole, simplifying the presentation-layer's task of updating the information shown to the user. The advantage is the back-end does not need to know which subset of customer data the presentation layer actually needs, and the presentation layer can pass the back-end only those parts that were really modified.</p> <p><strong>Update — technical note:</strong> Consider using a tool like <a href="http://automapper.codeplex.com/" rel="nofollow">AutoMapper</a> (C#) to automate translations between DTOs and DAOs. While this matter is a subject of technology used, generally this approach saves a lot of manual work and is able to eliminate hard-to-discover bugs. Having such an object translation automation in place helps promote better design practices and allows you to produce more-specialized and hence semantically more accurate DTOs.</p> <hr> <p><em>Disclaimer: While this is a rather general question, my recommendations may not seem right in respect to further details of your application which are not covered in your question.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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