DDD命令或查询中哪个是域模型?
我现在正在探索DDD,因此我看到许多人申请了CQR和活动采购。我的问题是哪个是域模型(命令或查询)?我们是否专注于命令模型行为而不是查询,因为只要命令模型有效,就可以从事件中构建查询模型。
I'm exploring DDD right now so I see many people apply with CQRS and Event sourcing. My question is which one is Domain model (Command or Query)? Should we focusing on Command model behavior rather than Query because query model can be built up from events as long as Command models are valid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
命令。
非常宽松地,查询被用来向我们的系统问题提出有关已经写下来的信息的问题。命令用于与我们的系统共享新信息,以便它可以写下新事物。
域模型是我们的“决定要写下的”代码寿命的地方;这是我们期望业务的“政策”执行的地方。
Command.
Very loosely, queries are used to ask our system questions about information that is already written down. Commands are used to share new information with our system, so that it can write new things down.
The domain model is where our "decide what to write down" code lives; it's where we expect the "policies" of the business to be enforced.
请记住,我不是这个主题的专家,而我上次读到这是很多年前。据我记得CQRS,查询取决于您最终还是直接的一致性。如果您需要立即的一致性,则不能使用事件队列来构建查询数据库,因为它太慢了,您需要维护一个单独的数据库以服务此类查询,因此可以在您的域模型中显示。对于正常查询,具有几秒钟延迟的构建查询数据库很好。因此,您的焦点通常是在域模型中的命令,但是CQRS并不总是可行。
Keep in mind that I am not an expert of the topic, and the last time I read about this was many years ago. As far as I remember CQRS the query depends on whether you need eventual or immediate consistency for it. If you need immediate consistency, then you cannot use the event queue to build your query database, because it is too slow and you need to maintain a separate database for serving these kind of queries, so this can show up in your domain model. For normal queries the built query databases with e.g. a few secs delay are fine. So your focus is usually command in the domain model, but CQRS does not always work.