何时使用CQRS设计模式? [英] When to use the CQRS design pattern?

查看:145
本文介绍了何时使用CQRS设计模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队和我一直在讨论使用CQRS(命令查询责任分隔)设计模式,我们仍然在努力评估使用它的利弊。根据: http://martinfowler.com/bliki/CQRS.html


我们在该领域还没有看到足够的使用CQRS,但没有足够的自信
,我们了解其利弊


那么你们怎么想,什么时候要使用CQRS?

解决方案

CQRS不是包含整个应用程序的模式。



这是一个以域驱动设计(DDD)为基础的概念。而DDD的一个重要战略概念就是所谓的有界的上下文。



在典型的应用程序中,有多个有界的上下文,其中任何一个可以通过有意义的方式实现。例如




  • 用户管理 - > CRUD

  • 发票 - > CRUD

  • 保险政策管理(核心域名) - > CQRS

  • ...



这可能不会回答您的问题,但可能会更多地了解该主题。说实话,我认为没有考虑到项目的具体细节,根本就不能回答,即使那样,很少有一个确定的最佳做法。


My team and I have been discussing using the CQRS (Command Query Responsibility Segregation) design pattern and we are still trying to asses the pros and cons of using it. According to: http://martinfowler.com/bliki/CQRS.html

we haven't seen enough uses of CQRS in the field yet to be confident that we understand its pros and cons

So what do you guys think, when does a problem call for using CQRS?

解决方案

CQRS is not a pattern that encompasses the whole application.

It is a concept that builds on Domain Driven Design (DDD). And an important strategic concept of DDD is the so-called Bounded Context.

In a typical application there are multiple bounded contexts, any of which can be implemented the way it makes sense. For instance

  • User Management -> CRUD
  • Invoicing -> CRUD
  • Insurance Policy Management (the Core Domain) -> CQRS
  • ...

This probably doesn't answer your question but it might give a little more insight into the topic. To be honest, I don't think it can be answered at all without considering a project's specifics, and even then there is rarely something like a definite best practice.

这篇关于何时使用CQRS设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆