domain driven design - How can I create this component from root in DDD? -
I have a question about using the DDD to solve the following scenarios.
I have 2 entities person
and email
one person can have a zero or more email address (SAS) .
person
is a group of a email
which is a component.
class person {set < Email & gt; Email = New Hashet & lt; Email & gt; } Class Email {String Value; Email (string value) {}}
I have 2 requirements in the system:
-
Users can send request to add a new email
-
The user can temporarily make a list of emails and add them to the person.
What does 3 methods mean in DDD? Or is there a better way to meet my needs.
-
To create a party by email, but do not add it to the email list (see
createEmail ())
below < Li> -
To create an email for an individual and add it to the email list (see
addEmail ()
below).
Being a separate method for adding email to the list (see setEmail ()
below).
The person in the public category {Set < Email & gt; Email = New Hashet & lt; Email & gt; Public Zero addEmail (String Value) {Email Email = Create Email (Value); Emails.add (email); } Create a public email e-mail (string value) {return new email (value); } Public Zero Set Email (Email Email) {emailss.add (email); }}
Personally, I will see it separately:
I see only 'person' as an institution. Email is a type of value and is not a unit, because it has no identity.
Then, I will highlight the person's e-mail address as a read-only collection of the person unit. Public Zero AddEmail (Email Mail) {} Public Zero AddEmail (String Mail Address) {} Public Zero RemoveEmail (Email Mail) {} Public Zero RemoveEmail (String Mail Address) {} Email [] GetEmailAdresses () {}; } Public Structure Email {Public Email (String Address) {} Public String Address {get {return _address; }}}
Comments
Post a Comment