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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.