문제

내 도메인 모델을 조금 이해하고 내가 디자인에 올바르게 접근하고 있는지 확인하는 데 도움이되는 도움을받을 수 있습니다.

부서라는 집계 루트가 있습니다. 부서 개체에는 '부서'의 비즈니스 개념을 정의하는 데 도움이되는 몇 가지 하위 값 유형이 있습니다. 내 UI 사용자는 부서 객체를 나열, 생성, 편집 및 삭제할 수 있습니다.

프로젝트라는 또 다른 집계 루트가 있습니다. 프로젝트에는 몇 개의 자식 가치 유형이 있지만 부서가 각 프로젝트가 '소유'라는 점에서 부서와의 관계가 있습니다. 프로젝트는 생성, 편집, 삭제 등을 만들고, 이렇게하면 부서를 제거하는 반면 부서를 제거하는 것이 부서에도 영향을 미치지 않습니다.

My UI는 현재 사용자가 액세스 권한이있는 부서에 따라 프로젝트 목록을 표시합니다. 그들은 둘 이상의 부서에 액세스 할 수 있습니다. 목록 항목과 자세한 내용은 모두 프로젝트가있는 부서 로고를 표시해야합니다.

첫 번째 생각은 프로젝트가 부서를 '조회'에 사용하는 데 사용할 수있는 간단한 부과 자산이있는 집계 루트였습니다. 하지만 이제는 내가 정말로 하나의 집계 루트 만 가지고 있다고 생각하기 시작했습니다.

어떻게 생각하세요?

업데이트

토론의 핵심인지를 모르지만 첫 번째 답변을 읽은 후에 다음과 같은 생각이 나에게 일어났습니다.

부서는 두 가지 컨텍스트가있는 것으로 보입니다.

  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