Im currently working on a system that will communicate with other systems via webservice (or some sort of communication). I have a system that stores all user data already and don't want to duplicate data in this new system so I have come up with a way of accessing the data when needed.
In my current system I am planning to just store the user ID from the user system and fetch the data when required. My question is, is the following code considered acceptable/understood or would you suggest an alternative way of achieving this?
public class Person
{
private string id;
[Transient]
private string name;
[Transient]
private bool isPopulated;
public Person(string id){
this.id = id;
}
public string Id{get;set;}
public string Name{
get{
init();
return this.name;
}
set{
this.name = value;
}
}
private void init(){
if(!isPopulated){
TempPerson tempPerson = UserService.getPerson(this.id);
this.name = tempPerson.Name;
this.isPopulated = true;
}
}
}
Is there a better way to do this and are there any problem with this way?