事件溯源项目结构

事件溯源项目结构

本文介绍了CQRS/事件溯源项目结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的第一个使用事件溯源的 CQRS 项目,我想知道与其他涉及多层的项目相比,这种类型的项目是否应该在 Visual Studio 中以不同的方式构建?

I have my first CQRS project which uses event sourcing and I was wondering if this type of project should be structured in a different way in Visual studio compared to other projects that involve multiple tiers?

例如,在过去创建的项目中,有一些层,例如远程处理、应用服务、域等,很明显每个层/程序集都触及了它下面的层.这些程序集似乎做了很多事情,使用像 NDepend 这样的工具确实说明了项目的结构.

For example, in the pastt projects created had layers such as Remoting, App services, domain etc and it was clear each layer/assembly touched the one below it. These assemblies seemed to do a lot and using a tool like NDepend did say much about the structure of the project.

但是,对于 CQRS 项目,是否最好只拥有显示其意图的较小程序集,即用于命令的程序集、另一个用于事件的程序集、另一个用于事件处理程序的程序集等.

However, with a CQRS project would it be better just to have smaller assemblies that show their intent i.e. assembly for commands, another for events, another for event handlers etc.

现在有了 NDepend,它可以让我更好地表示程序集的使用方式.

Now with NDepend it would give me a better representation how the assemblies are used.

推荐答案

我通常使用描述其意图的较小项目来构建我的 CQRS 项目——命令、域、事件、非规范化器、存储库、命令服务等.

I generally structure my CQRS projects with smaller projects that are descriptive of their intent -- Command, Domain, Event, Denormalizer, Repository, Command Service, etc.

这样可以更轻松地浏览您的解决方案,也让您团队中的其他人(或新加入的团队成员)更轻松地使用您系统的各种组件.

It makes it much easier to navigate through your solution this way, and also makes it easier for others on your team (or new team members coming on board) to work with the various components of your system.

此外,如果您有一个团队在做这方面的工作,您可以轻松地让一个团队主要专注于领域项目(可能是您的高端团队成员),而您的初级成员可以专注于非规范化项目.

Also, if you have a team working on this, you can easily let one group focus primarily on the domain project (probably your higher-end team members) while your junior members could work on the denormalizer project.

您最终会得到(可能)更多的项目,但它们会更小,更容易理解其目的.有点像单一职责原则,但在项目级别.

You'll end up with (probably) more projects, but they'll be smaller chunks and much easier to understand their purpose. Kind of like the Single Responsibility Principle, but at the project level.

希望这会有所帮助.祝你好运.

Hope this helps. Good luck.

这篇关于CQRS/事件溯源项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 10:19