Design Pattern help for this scenerio?.
I need some expert advice on possible ways
to design the classes for following scenerio.
Subject domain has 3 types of identities.
Lets say <IDType1>, <IDType2>. Because
both are identities and have some
commonality we can inherit them from a
base <Identity> type.
Then there is People who owns those IDs.
Some have only 1 ID and some have both.
The problem I have having here is this.
You should be able to add <Identity>
only with a person. So, basicaly I thought
to have a register method inside <Person>
which inturn call [Add] methods in IDentites.
Also, I cannot have [Add] methods inside
the IDType1, IDType2 classes as public
because then it will allow adding identites
without adding a <Person>
Having Identities as inner classes within
<Person> will solve the above issue,
but then, to provide functionality such
as listing/searching IDType1, IDType2
will also have to be done from <Person>
which is a bit silly (I guess)
Using internal keyword may be another
solution. But I think there can be a better
way of doing this.
Any body who can help me
with some design pattern here?
Regards
KK