CQRS和CRUD屏幕 [英] CQRS and CRUD screens

查看:76
本文介绍了CQRS和CRUD屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,CQRS的基本原则之一是命令应以行为为中心,并在业务或UL中具有价值,而不是以数据为中心,即CRUD。我们没有关注更新客户,而是使用诸如CustomerHasMoved之类的命令。如果您有可以纠正某些数据的CRUD屏幕,该怎么办。例如,我们需要更改拼写错误的客户名称。这实际上对业务没有太大价值。

One of the basic tenets of CQRS, as I understand it, is that commands should be behaviour-centric, and have a value in the business or the UL, and not data-centric, ie., CRUD. Instead of focusing on updating a customer, we have commands like CustomerHasMoved. What if you have CRUD screens which are there to correct certain data. For example, we need to change the name of a customer which is misspelled. This doesn't really have much value in the business. Should this just be under the umbrella of an UpdateCustomer command?

推荐答案

实际上,可能有多种原因来更新a的名称。顾客。就像您所说的那样,它可能拼写错误,或者...您可以结婚并将您的名字改成您丈夫的名字。

Actually, there could be various reasons to update the name of a customer. As you were saying, it could be misspelled or... you could get married and change your name to your husband's.

如果只有UpdateCustomer命令,则将失去原始意图,并且每个函数将无法具有不同的行为。如果名字错了,可能就像更新数据库一样简单,而如果您的客户结婚了,您可能需要通知市场部门以便他们提供折扣。

If you had only an UpdateCustomer command, you would loose the original intent and you would not be able to have different behaviours for each of them. If the name was misselled it could be as simple as updating the database, whereas if your customer got married you might need to notify the marketing departement so tthat they can offer a discount.

如果您的实体纯粹是CRUD,则没有意图与修改属性相关联,那么可以使用UpdateEntityCommand。然后,您可以慢慢过渡到更多基于任务的任务

In the case that your entity is purely CRUD, that is there is no intent that you can associate with modifying the properties, then it's OK to have an UpdateEntityCommand. You can then transition slowly to something more task based

这篇关于CQRS和CRUD屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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