Reputation: 1013
Defining domain model is most important task..unfortunately it is one hardest step in DDD. i like to know, how to design a simple domain model from the following statements .
"Every user must have a email to operate the system. the user must be registered using email and password.the administrator / user can initiate the registration process.once user successfully registered the admin must allot a predefined roles to the user, a single user can be assigned to many roles. after the registration process complete ,an email must be sent to the user regarding the credential details along with a welcome message.Every user have one or more key/value paired identifiers called Claims.So the admin able to assign the Claims to single or group of users."
This is may / mayn't look like a business requirement..but if some business expert explains something look like, then how we can shape a domain model from the above statements..can anyone identify the Entities,value objects,domain events,aggregate roots
Note: This question may be an off-topic considering the rules and regulations of stack overflow.instead of blocking /deleting this post ,please suggest me about where i can post it for getting some feedback.
Upvotes: 0
Views: 110
Reputation: 2691
The main purpose of DDD is to model the business rules in an explicit fashion. In your case, I see these rules:
I can't tell where the Claim object fits into this based on your question.
Here, it sounds like User is the aggregate root since it is what we will be operating on for all three of these requirements, thus you would have a class looking something like this:
public class User //Aggregate Root (mark this however you like)
{
public string Email { get; set; } //value object
//TODO: Ensure required rule from #1 above
public void Register(string email) { Email = email; }
//Rule #2 above
public event EventHandler<EventArgs> Registered; //Domain event - subscriber will probably notify admin of new registered user somehow.
public void AddRole(Role role) { //Code to add role; }
//Rule #3 above
private IEnumerable<Role> Roles { get; }
//Admin or the process admin uses will call this to notify the user after the role (and maybe claim assignments) are complete.
public void NotifyAboutRegistration(INotificationProvider provider)
{
string message = ""; //TODO: build string of welcome message with credential details from the description property of the Role type.
provider.SendWelcomeMessage(message);
}
}
public struct Role //Value object
{
public string Name { get; }
public string Description { get; }
}
Upvotes: 1