dolittle / Bifrost

This is the stable release of Dolittle till its out of alpha->beta stages
Other
110 stars 32 forks source link

When getting aggregate roots - it should allow for ConceptAs<> that are compatible for conversion to EventSourceId for the constructor #819

Open einari opened 7 years ago

einari commented 7 years ago

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
    {
    }
}