dotnet / dotnet/docs

POCOs domain classes and anemic domain model

Open
#32,978 1 comment 0 reactions 0 assignees View on GitHub
:watch: Not Triaged dotnet-architecture/svc microservices/subsvc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
19h 10m
Merged PRs (30d)
268

Description

Following the link to POCO's definition we see that they should include only props/fields and no methods. In this article we see that domain model classes should be POCOs. Isn't that the definition of an anemic domain model?

More specifically in [this page](https://learn.microsoft.com/en-us/dotnet/standard/glossary#poco) you can find the definition of a POCO. It states that:

A POCO—or a plain old class/[CLR](https://learn.microsoft.com/en-us/dotnet/standard/glossary#clr) object—is a .NET data structure that contains only public properties or fields. A POCO shouldn't contain any other members, such as:

- methods
- events
- delegates

These objects are used primarily as data transfer objects (DTOs). A pure POCO will not inherit another object, or implement an interface. It's common for POCOs to be used with serialization.

Then below Figure 7-5 we see:

---
![image](https://user-images.githubusercontent.com/48099304/205051937-ab7c46cf-6d27-4890-8c9c-9f9876ceec92.png)
---

which means they should include props/fields and no methods.

And then we see [the page](https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/microservice-domain-model#rich-domain-model-versus-anemic-domain-model):

---
![image](https://user-images.githubusercontent.com/48099304/205052514-efc2ba9d-d428-4f5c-9257-f0a8222c6d14.png)
---

and

---
![image](https://user-images.githubusercontent.com/48099304/205052579-80f3458d-9c05-458c-bc50-4ff81c3b3f0e.png)
---

from which I undestand that using POCOs for your domain models, the way POCO is defined above, results in an anemic model. That is why I am confused.

Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

ID: 95f3dcd7-3220-e9cf-3ca6-90b1282410ec
Version Independent ID: 5a30bea5-326b-ea72-59ae-dfef1e190e4a
Content: [Designing a DDD-oriented microservice](https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice)
Content Source: [docs/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice.md](https://github.com/dotnet/docs/blob/main/docs/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice.md)
Product: dotnet-architecture
Technology: microservices
GitHub Login: @nishanil
Microsoft Alias: nanil

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.