首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java项目组织

Java项目组织
EN

Software Engineering用户
提问于 2016-08-17 21:27:08
回答 1查看 3.6K关注 0票数 5

我只想听听关于java中一个DDD项目的这种项目结构的意见:

代码语言:javascript
复制
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)

适当的地方放置主要的方法。我想基础设施--消息传递和基础设施--休息是很自然的吗?

EN

回答 1

Software Engineering用户

回答已采纳

发布于 2016-08-17 23:58:17

我一直认为“域”部分应该准确地表示域,而不是其他任何部分。因此,对于我来说,领域项目通常由您在domain.models下列出的内容组成(事件等是模型的一部分,而不是单独的部分)。域只描述业务逻辑..。不要将存储库和服务接口保存在这里--这会污染域。

您可能有一个如下所示的域项目:

代码语言:javascript
复制
domain
    clients
    cases
    matters
    documents
    intakes

(域中的每个嵌套实体将根据需要进一步细分,等等)。这里的要点是,域代表的是业务实体,而不是其他任何东西。如果这是一条业务规则,当文档定稿时,X和Y必须发生(不管它是如何发生的),那么DocumentFinalized事件就是文档类的一部分,依此类推。将实现和持久性细节留给您的服务和存储库,只要它们满足域需求。

票数 2
EN
页面原文内容由Software Engineering提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://softwareengineering.stackexchange.com/questions/328648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档