Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We just had a hard time to find the answer to exactly this question in our project. This is the story:</p> <p>We thought that reusing classes is great and will reduce many repetitive stuff. NHibernate allows to detach and reattach classes from sessions, so it seemed to be trivial.</p> <ul> <li><p>First and biggest problem we had was that you can't send the whole database around, so we had to split the entity model into pieces and linked them by guids instead of normal references. This made queries very complicated.</p></li> <li><p>We had to implement some tricks because serialization, persistency and data binding all had their issues. This rather ugly hacks went all into the same classes. They became larger and larger.</p></li> <li><p>Attributes seem to be harmless, until you see a large list of attributes on each class and each property, because every layer adds its attributes.</p></li> <li><p>Entities implicitly started to support two "modes": an <em>DTO-mode</em> and a <em>persistency-mode</em>. This got evident when methods like <code>PrepareSerialization</code> or <code>AfterDatabaseRetrieval</code> and others of this kind showed up. Some properties could only be used in the server, others only in the client.</p></li> </ul> <p>Obviously, maintenance became a nightmare. Nobody took the risk of changing an entity anymore, because you had to change things in the whole system.</p> <p>Then we started to switch to Dtos.</p> <p>After a huge amount of work we managed to rewrite some important parts of the system to use Dtos. And - suddenly everyone got happy. </p> <p>You can maintain the serialization. You can maintain the database model and optimize queries. You could make changes on the cient model without breaking anything.</p> <p><strong>Conclusion:</strong> The effort to maintaining similar classes for each layers is ridiculous compared to the loss of maintainability when the same classes are used through all the layers.</p> <p>There are still some trivial entities and value-type kind of classes which are used as entities and Dtos at the same time.</p> <p>I could imagine that a small application that consists of only trivial entities could live without Dtos.</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. 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