Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid "Default Constructor Dependency" #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pietrom
Copy link

@pietrom pietrom commented Aug 24, 2018

In the README you wrote I hate the default constructor dependency needed to build Aggregates and Process Managers in the IRepository. I am not sure how to remove it :(.
I have tried removing it, handling first event of stream as a "special case" on rebuilding aggregates: I use (by reflection) a constructor with a signature like TAggregate(TEvent initEvent), constructor I use in the factory static method Create, too.

I tried an alternative approach, providing rebuilding functions of the form TEvent --> TAggregate and providing explicit rebuilders registration for initial events. This approach is less magic than using a specific constructor by reflection, but in my opinion it makes rebuilding logic and rebuilders registration more complicated and requires a full review of existing code; so I choose an approach that minimizes changes in existing code.

I would be happy to have your opinion about this (imho very interesting) topic.

@SneakyPeet
Copy link
Owner

Thanks for this PR.

I have not worked in .net land for quite a bit and for me to merge this would probably be quote the time investment. I may get to it, but probably not soon.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably add .idea to the .gitignore file in the root directory, and then remove the .idea directory & its six (6) files from your PR.

I haven't worked with that IDE much, but it seems like it's similar to .vs in that it's user-specific configuration info that doesn't belong in the repository.

@BjarkeMeier
Copy link

Why is the default ctor requirement a problem? It's the simplest ctor to use.

IMHO handling the first event of a series/stream of events as a special case only adds complexity to the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants