O'Reilly logo

Implementing Domain-Driven Design by Vaughn Vernon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required