Should an Aggregate Root Implement an Interface in Domain-Driven Design

前端 未结 2 1503
心在旅途
心在旅途 2021-01-18 04:55

I\'m working on a project using both domain-driven design and test-driven development. While reading through the DDD book by Evans, I noticed that he did not define interfa

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 05:16

    No, test directly against the aggregate. The aggregate itself shouldn't have injected dependencies and if a specific behavior requires a dependency, that should usually be expressed as an interface. An interface on an aggregate is a needless abstraction - there is only one implementation of behaviors - that is the point. Also, take a look at BDD and DDD - Behavior-Driven Development can be seen as an evolution of TDD and aligns nicely with DDD.

提交回复
热议问题