Command Handlers

Let’s consider the advantages of using Commands (4, 14) and Command Handlers to control the task management of our application. To start, first take another look at our Application Service and its LockCustomer() method:

public class CustomerApplicationService {   ...   public void LockCustomer(CustomerId id, string reason)   {     var eventStream = _eventStore.LoadEventStream(id);     var customer = new Customer(stream.Events);     customer.LockCustomer(reason);     _store.AppendToStream(id, eventStream.Version, customer.Changes);   }   ... }

Now imagine creating a serialized representation of the method name and its parameters. How might that look? We could create a class named for the application ...

Get Implementing Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.