Inheritance and Factories

Inheritance and Factories

Old forum URL: forums.lhotka.net/forums/t/2674.aspx


ksirmons posted on Tuesday, April 10, 2007

Howdy all,

 

I am working on a Medical Records application and think I need to use inheritance for some common behavior that all of my different medical record types use.

Examples of common behavior are record locking and change management.

 

I do not know what type of medical record a certain ID will be until I get some information from the database. 

Here is a quick and dirty run down of the database structure:  A common MR_Entry table that has the Medical Record ID and a Class.  The Class is what tells me it is a physical exam or a biopsy.  The Biopsy or Physical Exam each has their own database structures.

 

I would like to do something like:

Dim MR as new MedicalRecord(1234) and have the MedicalRecord not only get its common data from the database, but also determine it should be a biopsy (which inherits from MedicalRecord) and instantiates a Biospy for return to the MR.

 

 

Once I have the MR, I can examine its class property and based on that be able to tell if it is a Biospy or a PhysicalExam.

 

I will then take that MR in the GUI and load a custom control designed for Biospy and pass it the MR, letting the control worry about how to hook the data from the MR to the fields contained in the control.

 

Something like form.controls.add(mr.class + “.ascx”)

 

I am seeing generics and inheritance and factories dancing through my head, but can’t quite decide what will be the best way to execute this.

 

Thank you,

Keith

 

 

skagen00 replied on Tuesday, April 10, 2007

Hi Keith,

I do this exact thing.

Profiles for instance can be individuals or organizations.

I have the regular factory methods for individuals and organizations. GetIndividual(x), GetOrganization(x).

And I have a ProfileFactory class that has methods such as "GetProfile(x)", which I believe does an Exists() on individual & organization to narrow down which class's factory method it should delegate to.

Profile implements IProfile (thus Individual and Organization do so as well).

And GetProfile(x) on the ProfileFactory class returns an IProfile.

hope that helps.

Chris

 

Copyright (c) Marimer LLC