I'm a bit confused about the advise that inheritance be used to model objects that share behavior, not data. I have trouble making the distinction. Here is my situation. I am writing a web interface to an existing medical record system, so the database design is pretty much already determined. This is a medical records application, which typically has a different database table for each type of medical record (ie physical_exam, chemistry_test, radiology_exam, etc). Since there are many tables that may contain data for a given patient, we have a medical_record table that catalogs all of a patient's medical records. All of the various exam/treatment tables have a foreign key pointing to the medical_record table, which include the dates the record was created and updated, the users that modified the record, record type, description, and a foreign key pointing to the patient/visit record. So far, this is all shared data. Does that mean I should not use inheritance to model the business objects? For example, a physical_exam is-a medical_record, but does it behave-as a medical_record? The purpose of my physical_exam business object would be to allow display and data entry of physical exam data. I tend to want to have my physical_exam class inherit from medical_record so I don't have to reimplement properties for each field of data stored in the medical_record table and so I don't have to reimplement code to update the medical_record table. Should I use composition/delegation instead?
From what I've read on this forum so far, I expect to be advised to not use inheritance based on what I've said so far. I have two additional requirements that may qualify as "behavior". All medical records should have the ability to be "finalized", which means that they are electronically signed and can no longer be modified (a bit field in the medical_record table). Is that data or behavior? Also, I want to implement a record locking system whereby each record can only be edited by one user at a time. I intend to add a is_locked bit and lock_workstation_name fields to the medical_record table to prevent users from overwriting each others data.
What is your advise? Composition or Inheritance? Can you point me to csla examples?
Thanks,
Joel
Copyright (c) Marimer LLC