inN0Cent
inN0Cent

Reputation: 363

how can we model the behaviors of different types of users in DDD?

I am in a situation in which I am supposed to model (in domain) requirement where a user can be bill admin and system admin and employee.

All the Admins can do whatever the normal user can do, but a normal user cannot do what the other roles can do. The problem is that I dont understand how I can do this by inheriting the user entity and I have read thats not a good idea, so dont want to go that way..

The Employee, System Admin and Bill Admin are different roles of a user. Any suggestions?

Update :

More Information: Given that the Employees BC and Billing BC and System BC are three different Bounded Contexts what would be the ideal way of handling the above given scenario?

Upvotes: 2

Views: 1476

Answers (1)

Eben Roux
Eben Roux

Reputation: 13256

It may be that you are mixing bounded concepts and the inheritance is probably not helping either :)

Typically one would have an Identity and Access Control BC. This is where we may find a User, Permission, and a Role.

Then one may have an Employee or Human Resources BC. This is where concepts such as Employee and Manager may exist.

So it may help to split these concepts.

When a new employee is registered an EmployeeRegistered event may be published by the HR BC, using a service bus, that the I & AC BC subscribes to in order to register a new user.

Hope that helps.

Upvotes: 6

Related Questions