GOF vs CQRS中的命令模式含义 [英] Command Pattern in GOF vs CQRS meanings

查看:176
本文介绍了GOF vs CQRS中的命令模式含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查看命令模式时,发现有细微差别.也许有些人可以更清楚地说明这一点.

When Looking at the command pattern a found a slight difference. May be some is able to more clearify this.

查看四人行"时,它表示每个命令都有一个 Execute 方法,例如: http://www.blackwasp.co.uk/Command.aspx 像:

When looking at Gang Of Four it says that each command has a Execute Method see for example: http://www.blackwasp.co.uk/Command.aspx like:

myCommand.Execute(myValue);

现在,当我查看命令时, CQRS(Greg Young )我看到此命令没有execute方法.它们只是某种命令指令"实例.在CQRS网络广播中也说过类似的话.

Now when i look at the commands how there are used in CQRS (Greg Young) i see that this commands don't have an execute method. They are only some kind of "Command Instruction" instance. Similar things are said in the CQRS webcasts like.

该命令由domainobject处理. 喜欢

And the command is handled by the domainobject. like

class myDomainObject
{
    void UpdateValue(UpdateValueCommand cmd){
        this.value = cmd.value;
    }
}

这是否只是另一个CommandPattern定义,例如"CQRS-Command Pattern"?这样,当谈论一个命令时,它在公共"或"cqrs"上下文中可能会有些许不同的含义?还是我缺少命令模式或CQRS实现?

Is it right that it's just another CommandPattern definition like "CQRS-Command Pattern" ? So that when talking of a command it may have slight diffent meaning in a "common" or "cqrs" context? or am I missing something the command pattern or CQRS implementation?

推荐答案

好问题.

原始格式的命令模式就像GOF所说的.

Command pattern in its raw form is like GOF says.

在CQRS中,命令只是DTO(数据传输对象),因为在大多数情况下,CQRS是通过处理命令的事件或消息总线实现的.在CQRS中,您将命令发送到系统,并且系统具有某种总线或事件体系结构,允许自治组件订阅以处理命令.通过这种方式,您可以创建责任链,并且 SOLID 例如,用于读取和写入模型.

In CQRS the command is just a DTO (data transfer object) because CQRS is, in most cases, implemented with events or message bus that handles the command. In CQRS you send the command to the system and the system has some kind of bus or event architecture that allows autonomous component to subscribe to handle the command; in this way you can create a responsibility chain and it is more SOLID to, for example, work with read and write models.

它更像是责任链模式该命令模式,但保留了命令模式的优势,因为您仍然拥有命令,并且可以像命令模式中那样轻松地执行UNDO操作.

It is more a chain of responsibility pattern that command pattern but you keep the advantages of command pattern because you still have commands and can, for example, implement UNDO an action easily like in command pattern.

链接可以帮助您更好地理解CQRS.

This link can help you to understand CQRS better.

这篇关于GOF vs CQRS中的命令模式含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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