Hi,
I'm working on a some project in C#, and I came across the following problem:
I have some data-type classes, for example a Person class, which keeps information about a person.
In addition, I have a DataManager class, which is responsible of managing the persons in my program. If you want to add, get, find, or remove a person, you would do it only through the DataManager class.
The problem is that I don't want anyone besides the DataManager class to be able to alter the Person objects. If someone calls DataManager.getPerson(int ID) for example, they would get a Person object and would be able to use the setter functions of that Person object to alter its contents (first name, last name, ID, etc.).
I want to avoid that. I want only the DataManager class to be able to alter the Person objects (through methods such as DataManager.changeFirstNameForPerson(int ID, string name)).
What is the best class structure that can achieve that?
Thanks, Malki.