{public void AddUser(IUserIndexService index, string login, string password){if (index.IsLoginRegistered(login))throw ...Apply(new UserAdded(Guid.NewGuid(), login, password));}//VERSUSList<string> usernames = new List<string>();public void AddUser(IUserIndexService index, string login, string password){if (usernames.Contains(login))throw ...Apply(new UserAdded(Guid.NewGuid(), login, password));}}}Whats your opinions on this?Is it a way to get out of modeling of real aggregates?Tomas
One problem with the stateful List<String> approach is memory requirements. The domain service would (hopefully!) delegate to the persistent store to do the range query. If you hydrate aggregates on demand as well then every time you need to access that aggregate you have to replay every single one of those events.
One question is why is the uniqueness a consistency rule? A far more scalable approach is to allow collisions and compensate using an out-of-bound compensator (see http://codebetter.com/gregyoung/2010/08/12/eventual-consistency-and-set-validation/).
In my case its read model .. for 2 reasons
1) There are a lot of tools which do everything i need so why reinvent
the wheel .
2) Its a poor fit for CQRS . I dont really call logged in or not
business logic ,its just infrastructure.
On Thursday, January 10, 2013 10:43:53 AM UTC+1, Colin Yates wrote:One question is why is the uniqueness a consistency rule? A far more scalable approach is to allow collisions and compensate using an out-of-bound compensator (see http://codebetter.com/gregyoung/2010/08/12/eventual-consistency-and-set-validation/).If I can avoid it I really think that introducing inconsistent data into a system is a win. But it may just be preconceptions.
I would say that the creation is done through lets name it ManagerAR.Which sends out events which then creates a aggregate UserAR which each of the users can have for their sake and invoke commands on without locking or having concurrency conflicts with other users.But if they need to change for instance the username again, they would need to send that command to the ManagerAR.So you have eventual consistency between AR's.
Agree?
The other one yes can be argumented. That it probably won't happen in 99% of the time.
But then I still need to have a backup plan when it happens. :)
I just feel that using lookup services isn't really enforcing true invariants. It's a bit looser enforcing. Not as good. But works in most times.
Because the other is just an input as any argument which can be validated but not maybe always consistent?
Just a reflection.
Different opinions, not conflicting opinions.
Right. It is not "inconsistent". It is "eventually consistent". Inconsistent means wrong. Eventually consistent means "may not be the latest."
UserCredentials
Register(userid, credentialId)
Authenticate(username, password) -> UserCrendentialsAuthenticated(credentialid…)
Suspend()
Handle(NameCredentialReissued);
Handle(PasswordCredentialReissued);
Handle(NameCredentialIssued);
Handle(PasswordCredentialIssued);
where Authenticate with the original credentials succeeds and Authenticate with the new credentials fails until NameCredentialReissued and PasswordCredentialReissued are handled. (The two changes being independent of each other, of course.)
I see the username and password state held by UserCredentials in both of these cases as an eventually consistent partial replica of the official state in the NameCredentialRegistry (system of record).