M
M
magary42017-02-04 13:57:23
OOP
magary4, 2017-02-04 13:57:23

DDD Agregate, Entity, Repository in a clear language?

I have been smoking the topic of DDD for a long time
and I constantly get confused
how these 3 concepts interact?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry MiksIr, 2017-02-04
@miksir

Entity - the essence of the business. What is also called a "model", although this term is so fucked up that it's better not to remember it. What is our problem area working with? With the Client, with the manager, with orders, with the goods - these will be the entities. An important point is that an entity has a unique identifier.
A repository is a collection of entities, a pattern for managing entities. We get them from the repository, send them to the repository. The concrete implementation of the repository at the persistence level is already involved in persistence and retrieval of entities in databases.
With an aggregate, it’s both simple and difficult. When we design our subject area, we can highlight entities that should not be used in isolation from some other. For example, there are entities "contest" and "photo for the contest". The latter cannot exist without competition, cannot be used without it. At the same time, it is the "competition" that we will ask - how many photos came. When deleting a contest - you need to delete all photos of this contest. In such cases, we define summary (aggregate) boundaries and highlight the main entity (aggregate root or summary root). Refer "from outside", i.e. from other entities that are not part of the aggregate, we can only go to the summary root. We can only query the summary root from the repository. And so on, there are many restrictions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question