It increases readability and looks generally much better if we can allow having the actual domain concept as the constructor parameter for AggregateRoots / EventSources:
public class Messaging : AggregateRoot
{
public Messaging(Inbox inbox) : base((Guid)inbox) // Conversion to Guid - as we have implicit conversion to EventSourceId from Guid
{
}
}
Consider also if it makes sense to have a generic AggregateRoot:
public class Messaging : AggregateRoot<Inbox>
{
public Messaging(Inbox inbox) : base(inbox)
{
}
}
This would also make it easier for the next step; applying events:
public class Messaging : AggregateRoot<Inbox>
{
public Messaging(Inbox inbox) : base(inbox)
{
}
public void Receive(....)
{
Apply(new MessageReceived(eventSourceId) {....});
}
}
with an event:
public class MessageReceived : Event
{
public MessageReceived(Inbox inbox) : base((Guid)inbox) // Similar casting - or use generic here as well
{
}
}
It increases readability and looks generally much better if we can allow having the actual domain concept as the constructor parameter for AggregateRoots / EventSources:
Consider also if it makes sense to have a generic AggregateRoot:
This would also make it easier for the next step; applying events:
with an event: