返回首页

介绍
大多数的人谁得到与CQRS开始的问题,这个经典的例子:quot;我们如何验证用户名的唯一性,当新用户注册quot;
当用户身份验证是已实施之前无数次的东西,通常不应该推倒重来,而是使用现有的这种特殊情况下的软件库,本身的问题是相当有趣,不少发生在一个域。

When a user registers with a unique username

Then that registration should be approved

Given a user registration with a certain username was approved

When a new user registers with the same username

Then that registration should be rejected

在这个小文章中,我会告诉你一个简单的和适当的方式来解决问题的尊重CQRS /国内长途原则。是我们真正想要的吗?
让我们想起另一种方式解决问题。我将改写一点点的情景:{C}太好了,现在我们有一个悬而未决的注册!这是怎么有用吗?
没有那么快!我有一个经验法则:每当我有不同的AR的(即使是相同的AR类型的)之间的沟通,我用一个传奇。什么是独特性验证时,你想想看?没错!!所有其他AR的一个问题是,是否存在一个具有相同属性的实体。因此,让我们有一个传奇的第二场景:
Given a user registration with a certain username is pending

When the information is processed

Then it will approve the registration with that username

Given a user registration with a certain username has been approved

Given a user registration with the same username is pending

When the information is processed

Then it will reject the registration with that username

请注意,场景的传奇故事有一点不同:{体C3}示例代码{的C4}结论
有你有它,一个简单而优雅的解决一个问题大家开始奋斗。|汤姆・詹森:亚历克斯・科恩:微软Visual Studio提供了一个,准备工具,它是

回答