Loading...
Loading...
Marco Franssen

In this post, I expand on some notes I took during Greg Young's DDD/CQRS course in Krakow, Poland.
Domain-driven design (DDD) gives us some important things to think about. In particular, we distinguish between the following components:
An aggregate groups things that belong together. It should have a name that describes the whole.
My notes outline the following steps toward a domain-driven design:
When applying these ideas, keep the following points in mind:
Even without transactions, you can provide consistency in your systems through merging. The following code snippet illustrates this approach. Notice the recursive call in the catch clause.
public class MergingHandler<T> : Consumes<T>
{
public MergingHandler(Consumes<T> next)
{
}
public void Consume(T message)
{
try
{
var commit = eventStore.GetEventsSinceVersion(message.AggregateId, message.ExpectedVersion);
next.Handle(message);
foreach(var e in commit)
{
foreach (vat attempted in UnitOfWork.Current.PeekAll())
{
if (ConflictsWith(attempted, e)) {
throw new RealConcurrencyException();
}
}
}
UnitOfWork.Current.Commit();
}
catch(ConcurrencyException e) {
this.Consume(message);
}
}
}Marco Franssen
Lessons from applying DDD and CQRS in a Scrum project: bounded contexts, aggregate roots, domain services, guard methods, and command-based tests.
Marco Franssen
Configure Castle Windsor dependency injection in ASP.NET MVC 3 with an installer, controller factory, constructor injection, and repository disposal.