473,789 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoiding the God Class (Containment/Delegation or ??)

I'm designing a Windows Forms application for a medical clinic that keeps
complete and comprehensive histories on its patients: histories of medical
conditions and facts, financial facts, psychosocial evaluations, etc. There
is a whole bunch of stuff they track about each patient.

I am tentatively planning on implementing something close to the MVP
pattern, with this "Person" class at the BOL. The "Person" class would be
akin to the MVP model class.

As the scope of the project has increased, it seems that the amount of
information the business wants to track about their People keeps increasing.
My initial thoughts are that the Person class would contain a bunch of
other/helper classes (mostly to contain/manage various collections of
"things a person has" - like medication history, appointments, etc).

So my question: If my Person class comes to contain a large number of other
classes (mostly to manage collections of "things about the person"), is that
fact, by itself, a red flag in terms of good OOP design? I ask because, even
though I have separated out a lot of functionality (per MVP), this "Person"
class is starting to smack of the "god class" antipattern - simply because
it contains so much data.

How would I better manage all these facts about People - in the BOL - than
to have one big Person [model] class?

FWIW: The forms (screens) the users will see all need to show some common
data about the patient (name, medical record number), and then
"form-specific" data, like "social worker notes" or "medication refill
requests" etc.

Thanks!

Dec 19 '06 #1
3 2904
"Smithers" <A@B.coma écrit dans le message de news:
uT************* *@TK2MSFTNGP03. phx.gbl...

| How would I better manage all these facts about People - in the BOL - than
| to have one big Person [model] class?
|
| FWIW: The forms (screens) the users will see all need to show some common
| data about the patient (name, medical record number), and then
| "form-specific" data, like "social worker notes" or "medication refill
| requests" etc.

You have to be careful not to detach too much information, but the simplest
guidance is that, unless the Patient "owns" the information, it doesn't
belong in the Patient class.

Attributes like Name, Address, RecordNumber, etc, certainly belong in the
Patient, but most of the lists will belong outside. e.g. Appointment will
belong in an AppointmentBook class, Medication will belong in a Dispensary
class, etc.

This structure then also allows the modelling of the n-n relationships that
can occur in scenarios like the Dispensary class, where a Patient can have
multiple Medications and a Medication can be supplied to many Patients.

Classes like the AppointmentBook will have GetAppointments For(Patient)
method and GetAppointments For(Doctor, Date/Time) methods which will return a
list of Appointment objects, as well as a GetPatientsSeen On(Date) method
which will return a list of Patients, GetFrequencyFor (Patient), etc.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 19 '06 #2
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 .GetAppointment sFor(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.

--
Ciaran O''''Donnell
http://wannabedeveloper.spaces.live.com
"Joanna Carter [TeamB]" wrote:
"Smithers" <A@B.coma écrit dans le message de news:
uT************* *@TK2MSFTNGP03. phx.gbl...

| How would I better manage all these facts about People - in the BOL - than
| to have one big Person [model] class?
|
| FWIW: The forms (screens) the users will see all need to show some common
| data about the patient (name, medical record number), and then
| "form-specific" data, like "social worker notes" or "medication refill
| requests" etc.

You have to be careful not to detach too much information, but the simplest
guidance is that, unless the Patient "owns" the information, it doesn't
belong in the Patient class.

Attributes like Name, Address, RecordNumber, etc, certainly belong in the
Patient, but most of the lists will belong outside. e.g. Appointment will
belong in an AppointmentBook class, Medication will belong in a Dispensary
class, etc.

This structure then also allows the modelling of the n-n relationships that
can occur in scenarios like the Dispensary class, where a Patient can have
multiple Medications and a Medication can be supplied to many Patients.

Classes like the AppointmentBook will have GetAppointments For(Patient)
method and GetAppointments For(Doctor, Date/Time) methods which will return a
list of Appointment objects, as well as a GetPatientsSeen On(Date) method
which will return a list of Patients, GetFrequencyFor (Patient), etc.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Dec 19 '06 #3
"Ciaran O''''Donnell" <Ci************ @discussions.mi crosoft.coma écrit
dans le message de news:
E4************* *************** **...icrosof t.com...

|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 .GetAppointment sFor(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
Dec 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2142
by: E G | last post by:
Hi! I am having problems in designing a class. First, I have a base class that allocates a 3D data set and allows some other mathematical operations with it, something like this: template <typename T> class BasicArray {
9
5888
by: mead | last post by:
What kind of classes is qualified as "concrete classes"? When should a member function in a class defined as "pure virtual" and when as "virtual"? Thanks!
3
1507
by: Wilfried Mestdagh | last post by:
Hi, When do you put a class in another class and when not ? It seems in most case both work fine, but in some case not. I'm not yet smart enough in dotnet to know when and wy. Can someone enlighten ? I give example to enlight what I mean. This one has the CFG class in the class Rx: namespace TTLocator {
2
2435
by: russell.lane | last post by:
I'm building out a pretty standard n-tier web application. The stack includes application/presentation, biz logic, and data access layers on top of an SQL server back end. We want to use impersonation and delegation to forward the user's Windows login through all layers in the stack. To support this, I'm setting up a set of domain accounts which we use to create SPNs for the various services in the various layers. At this point, I'm...
4
3926
by: skishorev | last post by:
and what is object delagation, and how it can implemented?
10
2586
by: Smokey Grindle | last post by:
i want to inherit the list view class, but in the inherited class, hide the Header style property and the view property (basically its a detailed list with always clickable headers) how do I keep the base class properties from showing up in the inherited class when people change its properties in the IDE? thanks!
8
1989
by: Jackson | last post by:
I want a class that will determine its base class by the argument passed in. What I am about to write _does_not_work_, but it shows what I am trying to do. class ABC(some_super): def __init__(self,some_super): some_super.__init__(self) if some_super == list: self.append('ABC')
17
2237
by: Jef Driesen | last post by:
Suppose I have a datastructure (actually it's a graph) with one template parameter (the property P for each edge and vertex): struct graph<P>; struct vertex<P>; struct edge<P>; I also have an algorithm that modifies this datastructure. The basic outline of the algorithm is independent of the type of property. So I implemented a generic version of the algorithm and a function object for
6
2583
by: olympus_mons | last post by:
Hi, I generated C# classes from some complex XMLSchemas usind xsd.exe. The result is that I get a class hierarchy that is quite deep (well for me 8 levels are deep). What I'm curiuos about is, that if I create an instance of my top level element I still need to create instances of all sub-elements. What would be the best way to do some sort of "deep new" operator, that recursively creates instances for all sub-classes (the complete...
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9506
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.