c# – Methods in the Entity in DDD architecture

Question:

Could help me with a question. In DDD architecture which types of methods should I put in my Entity and which ones should I put in my Domain Service? I know that in my entity I must put at least the validation method of the entity itself, and when the rest of the methods must I put it in the domain service or are there other types of methods that I can put in the entity? Thanks.

Answer:

There are several approaches and choices that vary with specific domains, but in DDD the idea is to make the entity as "rich" as possible.

This means that if you can place the method on a specific entity, and keep its attributes private, this is the best choice. In other words, abuse Object Orientation (encapsulation and cohesion).

A domain service should only be created when the business rule does not "fit" in a single entity, having to use public properties of two or more entities.

Scroll to Top