Wednesday, November 5, 2008

Anemic vs. Rich Domain Models

There is an interesting discussion on stackoverflow: Why do we need entities?

When I read through this discussion, I get the impression that most people here are looking at entities in the sense of an Anemic Domain Model. A lot of people are considering the Anemic Domain Model as an antipattern!

There is value in rich domain models. That is what Domain Driven Design is all about. I personally believe that OO is a way to conquer complexity. This means not only technical complexity (like data-access, ui-binding, security ...) but also complexity in the business domain!

If we can apply OO techniques to analyze, model, design and implement our business problems, this is a tremendous advantage for the maintainability and extensibility of non-trivial applications!

There are differences between your entities and your tables. Entities should represent your model, tables just represent the data-aspect of your model!

s_wedding-ring.jpg It is true that data lives longer than apps, but consider this quote:
Models are forever ... data is a happy side effect.

-David Laribee



Some more links on this topic:
  • Why Setters and Getters are evil
  • Return of pure OO
  • Generalization - Another Gap between DB- and OO-Models
  • POJO vs. NOJO
  • Super Models Part 2
  • TDD, Mocks and Design

  • No comments:

    Post a Comment

    Related Posts Plugin for WordPress, Blogger...