Created
November 20, 2012 21:24
-
-
Save halllo/4121251 to your computer and use it in GitHub Desktop.
What do you think about the reuse of ContactInformation?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Address { } | |
class PhoneNumber { } | |
//Service 1 | |
class ContactInformations | |
{ | |
public ContactInformation PhoneNumbers() | |
{ | |
return new ContactInformation | |
{ | |
PhoneNumbers = new List<PhoneNumber>() | |
}; | |
} | |
public ContactInformation Addresses() | |
{ | |
return new ContactInformation | |
{ | |
Addresses = new List<Address>() | |
}; | |
} | |
} | |
class ContactInformation | |
{ | |
public List<Address> Addresses { get; } | |
public List<PhoneNumber> PhoneNumbers { get; } | |
} | |
//Service 2 | |
class Persons | |
{ | |
public IEnumerable<Person> All() | |
{ | |
yield return new PersonWithPhone(); | |
yield return new PersonWithAddress(); | |
} | |
} | |
class Person | |
{ | |
public string Name { get; set; } | |
public virtual void Remember(ContactInformation contactInformation) | |
{ | |
} | |
} | |
class PersonWithAddress : Person | |
{ | |
public List<Address> Addresses { get; private set; } | |
public override void Remember(ContactInformation contactInformation) | |
{ | |
Addresses = contactInformation.Addresses; | |
} | |
} | |
class PersonWithPhone : Person | |
{ | |
public List<PhoneNumber> PhoneNumbers { get; private set; } | |
public override void Remember(ContactInformation contactInformation) | |
{ | |
PhoneNumbers = contactInformation.PhoneNumbers; | |
} | |
} |
"I want to have a list of people, that I can send information to (e.g. christmas greetings), like in a CRM system. The contacts can have either a phone number or a mail address. Depending on what they have, the operator can call or mail the info. The above classes are to be used for seting up the mentioned list.
There are the two services, that provide the phone numbers and the contact addresses, and I want that data to be in a single list of persons."
Is that what you mean?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you try to express why you want these things?