Questions tagged [anemic-domain-model]

A domain model is "anemic" if it has little or no behavior. A model that only contains things, parties and places with no activities, is considered anemic. For example, a model that has only a 'Car' and a 'Car Dealership' is anemic because there is no activity (behavior) in the model that joins the two. For example, a 'CarSale' or 'CarService' activity represents behavior that joins the two and makes the model useful. Contrast with an "anemic object".

Having a domain layer that is only getters and setters for data values to/from the database is not a good OO design. Read more here

66 questions
124
votes
10 answers

Rich vs Anemic Domain Model

I am deciding if I should use a Rich Domain Model over an Anemic Domain Model, and looking for good examples of the two. I have been building web applications using an Anemic Domain Model, backed by a Service --> Repository --> Storage layer system,…
Sam
  • 15,336
  • 25
  • 85
  • 148
79
votes
4 answers

Avoiding anemic domain model - a real example

I am trying to understand Anemic Domain Models and why they are supposedly an anti-pattern. Here is a real world example. I have an Employee class, which has a ton of properties - name, gender, username, etc public class Employee { public string…
cbp
  • 25,252
  • 29
  • 125
  • 205
63
votes
7 answers

Single Responsibility Principle vs Anemic Domain Model anti-pattern

I'm in a project that takes the Single Responsibility Principle pretty seriously. We have a lot of small classes and things are quite simple. However, we have an anemic domain model - there is no behaviour in any of our model classes, they are just…
37
votes
5 answers

ASP.NET MVC Business Logic in Domain Model vs Service Layer

I have been reading about where to put business logic in ASP.NET MVC Project for a while and I still can't get clear on some things. 1 - Domain models. What are these really? In my Model folder I have only a bunch of classes corresponding to my…
27
votes
6 answers

Concrete examples on why the 'Anemic Domain Model' is considered an anti-pattern

I apologize if this is a duplicate, but I couldn't find any concrete examples on the topic in related questions. After reading Martin Fowler's article on the 'Anemic Domain Model', I'm left wandering as to why is this considered an anti-pattern.…
22
votes
2 answers

Can a "rich domain model" violate the Single Responsibility Principle?

An interesting thread came up when I typed in this question just now. I don't think it answers my question though. I've been working a lot with .NET MVC3, where it's desirable to have an anemic model. View models and edit models are best off as dumb…
20
votes
8 answers

If you are forced to use an Anemic domain model, where do you put your business logic and calculated fields?

Our current O/RM tool does not really allow for rich domain models, so we are forced to utilize anemic (DTO) entities everywhere. This has worked fine, but I continue to struggle with where to put basic object-based business logic and calculated…
Beep beep
  • 18,873
  • 12
  • 63
  • 78
19
votes
3 answers

anemic domain model versus domain model

Being confused again after reading about this anti-pattern and the many concerns about it here on SO. If I have a domain model and capture the data that must be persisted in a data transfer object, does that make my domain model a wrapper around the…
15
votes
2 answers

Domain Model and Service Layer patterns in P of EAA

In Patterns of Enterprise Application Architecture, Martin Fowler talks about two patterns for organizing Domain Logic: Domain Model and Service Layer. The Domain Model pattern is the "pure OOP" approach, where models (those objects that are…
14
votes
2 answers

DDD, Entity Framework, Aggregate Entity Behavior ( Person.AddEmail, etc)

Here's a simple example of a problem I'm running across that is not meshing with some of the ideas presented here and other places regarding DDD. Say I have an ASP.NET MVC 3 site that creates/manipulates a person. The controllers access an…
10
votes
3 answers

How Single Responsibility Principle relates to anemic/rich domain model?

Currently in doing some code review of stuff taken over from another team and have one doubt about applying SRP and its relation to anemic or rich domain model (as defined by Martin Fowler). Rich domain model concept is to have intelligent object…
7
votes
2 answers

How to avoid anemic domain model with business logic in the form of rules

I am designing a system that has a simple Entity Framework backed domain object that has fields I need to update based on a series of rules - I want to implement these rules progressively (in an agile style) and as I am using EF I am sceptical about…
6
votes
4 answers

Domain driven design: Avoiding anemic domains and modelling real world roles

I'm looking for some advice on how much I should be concerned around avoiding the anemic domain model. We are just starting on DDD and are struggling with analysis paralysis regarding simple design decisions. The latest point we are sticking on is…
g.foley
  • 2,152
  • 3
  • 19
  • 27
6
votes
2 answers

which metric(s) show the difference between object-oriented and procedural code

Which metric(s) could help to indicate that i have procedural code instead of object-oriented code? I would like to have a set of simple metrics, which indicate with a high probability, that the analyzed code contains procedural transaction scripts…
5
votes
2 answers

Domain objects - "Smart object" vs POCO

By Smart object I consider any Domain object that knows its original property value if property is altered. Smart objects usually have a base class and implement properties by using GetPropertyValue/SetPropertyValue methods. On the other hand POCO…
1
2 3 4 5