سؤال

يمكنني استخدام بعض المساعدة في فهم نموذج المجال الخاص بي قليلا وتأكد من الاقتراب من التصميم بشكل صحيح.

لدي جذر إجمالي يسمى القسم. يحتوي كائن القسم على العديد من أنواع قيمة الطفل التي تساعد في تحديد مفهوم العمل من "قسم". في مستخدمي المستخدمين الذين يمكنهم سرد، قم بإنشاء وتحرير وحذف كائنات القسم.

لدي جذر إجمالي آخر يسمى المشروع. يحتوي المشروع على العديد من أنواع قيمة الأطفال ولكن لديها أيضا علاقة مع قسم بهذا المشروع "مملوكة" من قبل قسم. يمكن إنشاء المشاريع، التي تم تحريرها، حذفها، وما إلى ذلك، وبالتالي لا يوجد لها تأثير على الإدارة، في حين أن إزالة القسم يزيل أيضا أي مشاريع تملكها.

سيعرض واجهة المستخدم الخاصة بي قائمة بالمشروعات بناء على الإدارات، المستخدم الحالي مخول بالوصول إليه. قد تكون قادرة على الوصول إلى أكثر من قسم واحد. عند عرضها ككل عنصر قائمة بالإضافة إلى التفاصيل، أحتاج إلى إظهار شعار القسم مع المشروع.

فكرتي الأولى كانت المشروع كان جذر إجمالي مع خاصية بسيطة يمكن استخدامها لإدارة "البحث". ولكن الآن بدأت أعتقد أن لدي حقا جذر واحد فقط: قسم.

ما رأيك؟

تحديث

لا أعرف ما إذا كان مفتاح المناقشة أو تغيير أي شيء، لكن الفكر التالي حدث لي بعد قراءة أول مجموعة من الإجابات. يبدو أن قسم

لديه سياقتين:

  1. ككيان مستقل يدعم التعديل.
  2. كطفل لمشروع يتضمن القضية بيانات للقراءة فقط و لا سلوك.

    هذا يجعلني أعتقد أنه يجب أن يكون لدي اثنين من الأشياء "في النموذج الخاص بي، جذر إجمالي للحالة # 1 ونوع القيمة للحالة رقم 2. هل أنا على المسار الصحيح؟

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top