Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 597 Bytes

ddd.md

File metadata and controls

27 lines (18 loc) · 597 Bytes

Domain Driven Design

Avoiding mutation

We have to avoid mutations, we have to use encapsulation to protect our domain state from changes made to other services without checking business rules.

Use readonly properties

Instead of:

public string Name { get; set; }

Use:

// The property is initialized in the constructor
public string Name { get; }

// In C#9 we can use init
public string Name { get; init; }

Rich vs Anemic domain model

We have to avoid classes void of behavior in domain models.

https://martinfowler.com/bliki/AnemicDomainModel.html