我只想听听关于java中一个DDD项目的这种项目结构的意见:
com.some.namespace
application
services = (app services that talk to repositories and domain model)
validators = (validators for DTOs in app service layer)
domain
events = (domain events)
exceptions = (exceptions in domain - eg. during validation or business logic)
factories = (used to construct domain model objects - eg. construct from DTOs)
model = (full domain model with all entities, value objects etc.)
repositories = (interfaces only - implemented in infrastruct.)
services = (domain service interfaces only - implemented in infrastr.)
infrastructure
messaging = (message listeners - eg RabbitMQ - talks to app services)
repositories = (repository implementations)
sql = (one version of repository implementation)
rest = (rest endpoints - talks to application services)
services = (domain service implementations)适当的地方放置主要的方法。我想基础设施--消息传递和基础设施--休息是很自然的吗?
发布于 2016-08-17 23:58:17
我一直认为“域”部分应该准确地表示域,而不是其他任何部分。因此,对于我来说,领域项目通常由您在domain.models下列出的内容组成(事件等是模型的一部分,而不是单独的部分)。域只描述业务逻辑..。不要将存储库和服务接口保存在这里--这会污染域。
您可能有一个如下所示的域项目:
domain
clients
cases
matters
documents
intakes(域中的每个嵌套实体将根据需要进一步细分,等等)。这里的要点是,域代表的是业务实体,而不是其他任何东西。如果这是一条业务规则,当文档定稿时,X和Y必须发生(不管它是如何发生的),那么DocumentFinalized事件就是文档类的一部分,依此类推。将实现和持久性细节留给您的服务和存储库,只要它们满足域需求。
https://softwareengineering.stackexchange.com/questions/328648
复制相似问题