Вопрос

I have some big Entity. Entity has propertis "Id", "Status" and others. I have Repository for this Entity. I want to change status in one entity. Should I get whole Entity, change property Status and use save method in Repository or should I use method ChangeStatus(id, newStatus) in Repository?

Это было полезно?

Решение

Probably you don't need a domain model. You could try a transaction script that directly use SQL to update the database.

You need a domain model if and only if you need to hire an expert to understand the business. Otherwise, it's just expensive buzzwords driven development.

And btw, if you have big entity classes containing data that you don't need during most of operations, then you know that you haven't properly defined context boundaries.

The best definition of bounded context is the one of Evans:

The delimited applicability of a particular model. BOUNDING CONTEXTS gives team members a clear and shared understanding of what has to be consistent and what can develop independently.

That is: you have to split the domain expert knowledge in contexts where each term has an unambiguous meaning and a restricted set of responsibility. If you do so, you'll obtain small types and modules with high cohesion an

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top