"Ciaran O''''Donnell" <(E-Mail Removed)> a écrit
dans le message de news:
E4D7FF76-B678-4610-BA22-(E-Mail Removed)...
|I agree with the below but would add that IMO it is good for the patient to
| have an Appointments property which returns (probably cached) result of
| AppointmentBook.GetAppointmentsFor(Patient).
| That not a GOD class as it isnt responsible for the information in the
| AppointmentBook or Appointment classes, it can just serve them to you.
I come up against this a lot when consulting for companies whose systems
have gotten way too complicated to maintain or update :-)
OO design, was always and still is, meant to be about modelling the real
world rather than having to create some relational absraction. In the real
world, you would not ask a Patient for their list of Appointments; do you
know every appointment you have ever kept ?
Also adding a GetAppointments method to the Patient class implies that you
should be able to get a list of all appointments, not just with a medical
practice - solicitor, lunch, etc are also appointments.
Another consideration is that Patient is not necessarily the best class in
which to hold personal information like Name, Address, DoB, etc. What if a
Patient is also a Doctor or Nurse at a practice ? Do you duplicate that
personal information in the Doctor or Nurse class ?
Where there is a possibility of a person being (e.g.) a patient and a nurse,
then it is advisable to separate out a Role base class, from which roles
like Doctor, Nurse, Patient, Receptionist, etc can derive. Then you *will*
have a list of Role objects in the Person class.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer