| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a fork of the Simple CQRS and eventsourcing with eventstore and elasticsearch by mastoj
Feel free to use issues or open pull requests as a means of discussion
The functionality of this solution is identical to the parent and all tests pass, but it reflects my personal opinions on best practices for implementing DDDesigns in C#
Most of the changes center around the belief that project structure should reflect the conceptual layers of your application, and most significantly that the Domain project should not entertain any concerns that are not to do with business decision making, for example command handlers.
The introduction of a project representing the Application Layer is the key difference. All command handlers reside here, and this project is the ONLY one in the solution allowed to reference the domain. From this perspective - even though methods on aggregate roots may be public - integrity of the domain is assured.
This extra granularity allows for Entities to be scoped more restrictively than Aggregate Roots... the former can now be made inaccessible to command handlers which was not possible in the parent sample. It is for this reason that the project structure used in this sample is important and should be preferred over mixing handlers and aggregate roots in the same project.
This is perhaps the most contraversial aspect of this implementation. It is important to note that the static class is simply a facade for an Action<object> that allows us to avoid taking a dependency in our domain. While this is a grand debate that I will not enter into here, I will at least summarise the thinking behind choosing this approach.
If we approach the problem theoretically and from outside the current constraints of the C# language... the ideal scenario would be if we had the ability to raise events natively in code, i.e via a first class language construct such as what we use for exceptions. This would allow us to implement our decision making code without polluting it by tracking code or having to return events from aggregate roots.
Given that this is not possible at present... it was decided that use of a static class facade over an event dispatcher scoped to logical call context so as to be thread safe was the next best thing. I consider this to be the least worst option as it allows us to keep our Aggregate roots clean and free of non-decision making concerns.
| Back | FazBrowse Home | New Git URL |