Event Serializers

It’s wise to choose a serializer that favors versioning and renaming Events. This is especially true early on in an A+ES project as the domain model tends to evolve rapidly. Consider this Event, which is declared using a .NET implementation of Protocol Buffers1 annotations:

1. Protocol Buffers was originated by Google. Others have created .NET implementations.

[DataContract] public class ProjectClosed {   [DataMember(Order=1)] public long ProjectId { get; set; }   [DataMember(Order=2)] public DateTime Closed { get; set; } }

Now, if we were to serialize ProjectClosed using DataContractSerializer or JsonSerializer rather than Protocol Buffers, any renamed members could easily break dependent consumers. ...

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.