J
Jordan
Suppose I have a system that keeps track of 5 different types of "People".
My intent is to have a base Person class, then 5 derived classes for each of
the specific person types (e.g., Patient, Doctor, Employee, Contractor,
etc).
Now, at runtime I need to retrieve all the property values from a database
and populate all of the fields of both the base and derived classes. Not all
fields will need to be exposed via public properties as they will be used
internally (to the class).
I would like to have one single method that talks to the DAL and populates
all fields.
What is the standard (or at least an acceptable) way to make this happen?
Should I put some "PopulateMe()" method (which calls the DAL) in the derived
class AND have it populate the base class fields? Something just doesn't
seem right about doing it that way... but the alternative would apparently
be to have some sort of "PopulateMe()" method in both the base class and
derived class - each one populating its respective fields. But that seems
sort of wrong as well.
Thoughts? Opinions? Perspective? Recommendations?
Thanks!
My intent is to have a base Person class, then 5 derived classes for each of
the specific person types (e.g., Patient, Doctor, Employee, Contractor,
etc).
Now, at runtime I need to retrieve all the property values from a database
and populate all of the fields of both the base and derived classes. Not all
fields will need to be exposed via public properties as they will be used
internally (to the class).
I would like to have one single method that talks to the DAL and populates
all fields.
What is the standard (or at least an acceptable) way to make this happen?
Should I put some "PopulateMe()" method (which calls the DAL) in the derived
class AND have it populate the base class fields? Something just doesn't
seem right about doing it that way... but the alternative would apparently
be to have some sort of "PopulateMe()" method in both the base class and
derived class - each one populating its respective fields. But that seems
sort of wrong as well.
Thoughts? Opinions? Perspective? Recommendations?
Thanks!