DDD 中的共享功能
我正在考虑向 DDD 项目添加功能,但我不确定适合它的最佳方法。
所需的功能是标记和用户组操作。
由于许多东西都是可标记的(用户、日记、文档等),因此在每个 AR 中重新创建该功能似乎是反 DRY 的。拥有一个维护中央标签表的标签存储库,然后为所需的不同标签类型(即将标签与 userId、journalId 等相关联)或什至单个多对多表提供各种多对多表是否明智?许多记录关系类型的表。如果是这样,是否必须修改域对象才能保存标签的链接?
群组功能类似。需要允许用户创建用户组,然后将组分配给非公共实体(期刊、文档等)以授予他们查看访问权限。
将这个新功能添加到项目中的最佳方法是什么?
I'm looking at adding functionality to a DDD project but I'm unsure of the best way to fit it in.
The needed functionality is tagging and user groups manipulation.
As many things will be taggable (users, journals, documents etc) it seems anti-DRY to recreate that functionality in each AR. Would it be sensible to have a Tag Repository which maintains a central tag table, then have various many-to-many tables for the different tagging types needed (i.e. associating tags to userId, journalId etc) or perhaps even a single many-to-many table which records the relationship type. If so, would the domain object have to be modified to hold the link to the tags?
The group functionality is similar. There is a need to allow users to create user groups, and then assign groups to non-public entities (journals, documents etc) to give them view access.
What would be the best way to add this new functionality to the project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为标记和组功能设计单独的有界上下文。
Design separate bounded contexts for tagging and the group functionality.
DRY 原则被表述为“每条知识都必须在系统内有一个单一的、明确的、权威的表示”。
通过分离,您可以促进 DRY 知识的明确和权威的表达。
The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.".
By separating, you promote the unambiguous and authoritative representations of the knowledge DRY is all about.