Domanda

Ive ha guardato un po 'di tempo in altri post in là relativly ad aggregati radici. E sembra che non capisco affatto come definire nel modo giusto aggregati radici. Ho visto le risposte, come aggregati radici potrebbero non essere aggregati radici e viceversa. Sono un po 'confuso. Il problema è che ho modello relazionale in testa, ma so che DDD non andrà in questo modo.

C'è un modo per definire radici di aggregazione da un modello relazione?

Esempio, se si dispone di un ufficiale che voci di diario attesa , che detengono ciascuna compiti, problemi, e le note

Come definirebbe gli aggregati radici? È la radice di un ufficiale ? ma che può causare problemi se si vuole note di accesso, problemi e compiti. Così sono thoses aggrega anche radici che tengono riferimento alle voci del diario?

Il suo qualcosa di difficile da capire e mi piacerebbe avere un po 'di chiarezza.

Grazie.

È stato utile?

Soluzione

I agree with you that the concept of aggregate roots can be confusing until you get your mind around it. Like most other concepts it gets easier with practice, working it through a few times.

The point of the aggregate is to simplify object traversal for some external obect, in the context of one or more use case(s). You have to start somewhere to satisfy a business requirement, and if you find that you are largely needing a Journal, it's like that it should in fact be an aggregate root. In most domains that aren't trivial, you will find it useful to have more than one aggregate root. There is nothing supernatural about the starting object for a use case. You just need to start somewhere.

But again, the point is to simplify object traversal, which simplifies your system. So if Journal is in fact a useful starting point, make all of your calls to Journal first. If a particular use case will wind up needing Tasks, Money, Time or any other useful things, the calling program gets those things by asking Journal, and only Journal. The other objects are part of the Journal aggregate root, for this use case.

For other use cases, it may be more natural and therefore useful for Task to be the starting point, and so you may have a Task aggregate root too, which will likely overlap your Journal aggregate root of use cases. But you ask Task and only Task to satisfy the request (be the only reference that the calling program needs to know about)

Your relational db can and will stay relational of course. But by having your object model evolve to look at requests from an aggregate (starting point object) point of view, your requests from the db will wind up being simpler.

Lay out a use case (or two) and try and work it through. Ask questions within the context of the use case if you like.

HTH,
Berryl

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top