保存、进度、DDD、实体

发布于 2024-10-16 00:20:45 字数 112 浏览 12 评论 0原文

我是领域驱动设计的新手。我有一个网络应用程序,用户可以通过任务保存进度的中间结果,即将表单上的数据另存为草稿,然后再回来填写。如果表单代表一个实体并且它是聚合的根,那么可以根据状态将实体保存为半生不熟的状态吗?

I'm new to Domain driven design. I have a web application where user would be able to save intermediate results of progress through a task i.e. saving as data on a form as draft and coming back to fill it later. If the form represents an entity and its the root of the aggregates, is it ok to save the entity in half-baked state based on status?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懒猫 2024-10-23 00:20:46

视情况而定,对此确实没有正确的一般答案。

虽然可以走这条路,但它可能会干扰我倾向于遵循的另一条原则,即任何域对象都不能处于无效状态。

由于子系统的域是表单的提交,尽管按状态执行此操作可能是合乎逻辑的 - 即域本身不排除半填写的表单,因此只有在提交时才需要填写所有必填字段的规则真正发挥作用。

例如,半填写的表格有效可能很有意义 - 特别是如果表格需要经过工作流程(例如获得主管签字)直到可以算作完整

Depends, there really is no correct general answer to this.

While one can go this route it could interfere with another principle I tend to follow which is that no Domain Object can be in an invalid state.

Since the Domain of your subsystem is a submission of a form though it might be logical to do this by state - that is the domain itself does not exclude half filled in forms, only on submission does the rule that all mandatory fields need to be completed really comes into affect.

For example it might make alot of sense for a half filled in form to be valid - especially if the form needs to go through a workflow (such as get supervisor signoff) till it could be counted as being complete

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文