Frage

Ich könnte etwas Hilfe verwenden, um mein Domain-Modell ein bisschen zu verstehen und sicherzustellen, dass ich dem Design richtig nähere.

Ich habe eine Aggregatwurzel namens Department. Das Abteilungsobjekt verfügt über mehrere untergeordnete Wertentypen, die dazu beitragen, den Geschäftsbegriff von einer "Abteilung" zu definieren. In meiner UI-Benutzer können Abteilungsobjekte auflisten, erstellen, bearbeiten und löschen.

Ich habe ein weiteres Aggregatwurzel mit dem Namen des Projekts. Ein Projekt hat mehrere Kinderwerttypen, hat aber auch eine Beziehung zu einer Abteilung, in der jedes Projekt von einer Abteilung gehört. Projekte können erstellt, bearbeitet, gelöscht werden usw. usw. haben keine Auswirkungen auf die Abteilung, während das Entfernen einer Abteilung auch alle Projekte entfernt, die sie besitzt.

Meine UI zeigt eine Liste von Projekten an, die auf den Abteilungen basierend auf den Abteilungen basiert, der der aktuelle Benutzer zugreifen kann. Sie können möglicherweise auf mehr als eine Abteilung zugreifen können. Wenn Sie sowohl als ein Listenelement als auch im Detail angezeigt werden, muss ich das Abteilungslogo mit dem Projekt anzeigen.

Mein erster Gedanke war das Projekt eine aggregierte Wurzel mit einem einfachen Department-Eigentum, das zur "Lookup" der Abteilung verwendet werden konnte. Aber jetzt fange ich an zu denken, dass ich wirklich nur eine Aggregatwurzel habe: Abteilung.

Was denkst du?

update

Ich weiß nicht, ob es der Schlüssel zur Diskussion ist oder irgendetwas ändert, aber der folgende Gedanke trat mir nach dem Lesen der ersten Antworten auf.

Abteilung scheint zwei Kontexte zu haben:

    .
  1. als eigenständige Entität das Unterstützt die Änderung.
  2. als Kind eines Projekts, in dem Fall ist nur schreibgeschützte Daten und kein Verhalten.

    Das ist, dass ich denke, dass ich zwei 'Objekte in meinem Modell haben sollte, eine Aggregatwurzel für den Fall # 1 und einen Werttyp für den Fall # 2. Bin ich auf dem richtigen Weg?

War es hilfreich?

Lösung

Since the Project can't exist without a Department it's probably not an Aggregate Root. From your description it sounds like you only have one AR - the Department, which you use to manage the projects inside it.

If your behavior is mostly CRUD, i would not recommend building a full blown domain model for it since there are probably simpler approaches you can take.

UPDATE As you mention, you might have 2 bounded contexts here. One where the Department is an AR and the Projects are entities of this AR. In this context you would perform operations on your Departments. In a second BC your Project could be the AR and the Departments could be entities or VOs. This would allow you to work directly with projects.

I would also recommend going over this with your domain expert and see if these concepts fit well in your UL, or maybe search for some missing concept that can clarify your model. I would especially look for a concept that might link projects to departments.

Andere Tipps

I think it's perfectly defensible to have both Project and Department be aggregate roots, since they are both managed independently.

That is, every Project and every Department have some kind of unique identifier, and while you can add Projects to Departments, Projects themselves are probably complicated enough (with their own lifecycles, their own child objects etc.) to warrant aggregate root status.

You just have to keep a reference to the Department in each Project.

Few simple questions to be answered:

1) can the department domain object live by its own without the Project domain object. - If yes, then the department is an aggregate.

2) Is the Project domain object can live by its own - If yes, then the Project is also an aggregate

3) Is Project has relationship with one Department - Then it should be part of the Project aggregate exposed as property Department

4) Is Department has relation ship with one or more Project objects - The the Project aggregate should be part of the Department aggregate object.

So, Using Department aggregate object you might need to access the list of Project(s) object and once you have the Project object you might need to access the Department object. It is a circular reference which is obsoletely fine.

It is a typical example of Employee has a manager and manager has a list of employees

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top