I am working on some project in C # and I ran into the following problem:
I have some data type classes, for example, the Person class, which stores information about a person.
In addition, I have a DataManager class that is responsible for managing people in my program. If you want to add, receive, find or delete a person, you would only do this through the DataManager class.
The problem is that I do not want anyone other than the DataManager class to be able to modify Person objects. If someone calls DataManager.getPerson(int ID), for example, they will receive a Person object and be able to use the setter functions of this Person object to change its contents (first name, last name, identifier, etc.).
I want to avoid this. I want only the DataManager class to be able to modify Person objects (using methods such as DataManager.changeFirstNameForPerson(int ID, string name)).
What is the best class structure that can achieve this?
Malki source
share