Let's take some blogging application. User in this application has email, password. When a new user is registered, he should activate his account (for example, via email). But... is account activation, password, password reset tokens, etc, are domain concepts?
So I'm thinking to divide User concept into 2 parts: Account and Member. An Account is non-domain concept, it will handle activation, password reset, etc. But Member is domain concept, a member does not anything about passwords, activation, etc.
An Account will have reference to a Member.
What do you think about this approach? or may User be a part of domain?
accountManager.tryLogin(user,passwd)
oraccountManager.createAccount(…)
. Thenaccount.changePassword(…), account.activate(…)
are operations in the account context. In the blog context, we have a Member withmember.getPosts()
ormember.getUsername()
operations. When a user logs in (account context), how do we get the corresponding Member (blog context) so that they can write a post? Something likemembers.getMemberForId(account.memberId)
allows us to cross the context boundary without mixing the different models. – amon Dec 13 '16 at 15:25