title: Anemic Model vs DTO vs Active Records
body: <p>It's not very clear to me how a class should be designed:</p>
  
  <ul>
  <li><a href="http://en.wikipedia.org/wiki/Anemic_domain_model" rel="nofollow noreferrer">Anemic Model Domain</a> states:</li>
  </ul>
  
  <blockquote>
    <p>The fundamental horror of this anti-pattern is that it's so contrary
    to <strong>the basic idea of object-oriented designing; which is to combine
    data and process them together.</strong> The anemic domain model is just a
    procedural style design, exactly the kind of thing that object bigots
    like me ... have been fighting since our early days in Smalltalk.
    What's worse, many people think that anemic objects are real objects,
    and thus completely miss the point of what object-oriented design is
    all about. In an anemic domain design, business logic is typically
    implemented in separate classes which transform the state of the
    domain objects. Fowler calls such external classes transaction
    scripts. This pattern is a common approach in Java applications,
    possibly encouraged by technologies such as early versions of EJB's
    Entity Beans, as well as in .NET applications following the
    Three-Layered Services Application architecture where such objects
    fall into the category of "Business Entities" (although Business
    Entities can also contain behavior)</p>
  </blockquote>
  
  <ul>
  <li><a href="http://en.wikipedia.org/wiki/Data_transfer_object" rel="nofollow noreferrer">DTO (Data Transfer Object)</a></li>
  </ul>
  
  <blockquote>
    <p>The difference between data transfer objects and business objects or
    data access objects is that a DTO does not have any behavior except
    for storage and retrieval of its own data (accessors and mutators).
    DTOs are simple objects that should not contain any business logic
    that would require testing.</p>
  </blockquote>
  
  <ul>
  <li><a href="http://en.wikipedia.org/wiki/Active_record" rel="nofollow noreferrer">Active record</a> pattern</li>
  </ul>
  
  <blockquote>
    <p>Refer to wikipedia</p>
  </blockquote>
  
  <ul>
  <li>Now refer also to this Q&amp;A: <a href="https://stackoverflow.com/questions/22382352/how-is-called-dto-class-that-also-access-db">How is called DTO class that also access db?</a></li>
  </ul>
  
  <p>It seems that <strong>DTO should be only been used to share data between webservices</strong>, <strong>but</strong>, at the same time, <strong>Active Record which are aware of their persistance on DB are also bad</strong>. </p>
  
  <p>So which kind of logic should be putted in the class which are cointaining the data taken from the database?</p>