dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.28k stars 5.91k forks source link

POCOs domain classes and anemic domain model #32978

Open kosletr opened 1 year ago

kosletr commented 1 year ago

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 you can find the definition of a POCO. It states that:

A POCO—or a plain old class/CLR object—is a .NET data structure that contains only public properties or fields. A POCO shouldn't contain any other members, such as:

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

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

And then we see the page:


image

and


image

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 Content Source: docs/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice.md Product: dotnet-architecture Technology: microservices GitHub Login: @nishanil Microsoft Alias: nanil

erjain commented 1 year ago

Hi @ardalis, adding you to this.