473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

class design question

SB
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment
that is basically a doctors scheduling program, i.e. for three doctors show
their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.

Thanks in advance!
Jul 22 '05 #1
5 1971
* "SB" <vo******@hotmail.com> schriebt:
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment
that is basically a doctors scheduling program, i.e. for three doctors show
their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.


There are always guidelines, but if this problem could be described by easy to
follow rules then it could be automated, and you wouldn't be asked to do it.

Best advice: stop thinking about things you don't grok (classes) and start
analyzing how this works in real life (on paper) and start coding (on a computer).

Be prepared to throw away everything you've done at least once and hopefully also
twice and thrice; -- _then_ you're getting somewhere.

PS: Also, please post to a relevant group. This answer is cross-posted to
[comp.programming], and follow-up is set to [comp.programming]. You're
off-topic in [comp.lang.c++].

Jul 22 '05 #2
"SB" <vo******@hotmail.com> wrote in message
news:u0d_b.14387$Dc2.7710@lakeread01...
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment that is basically a doctors scheduling program, i.e. for three doctors show their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.

Thanks in advance!


That's a pretty general question. I would say a well designed class
shouldn't contain two things that really have nothing to do with each other.
(Sounds simple, doesn't it?) I would also say it is better to avoid member
functions which could have been written entirely using the rest of the
interface. It's better for encapsulation if these "helper functions" are
written as standalone functions. Don't write get/set functions for each data
member. You should be able to set the data values using the constructor.
Don't use operator new() unless you have to. If you need a destructor, a
copy constructor, or an assignment operator you almost certainly need all
three. (For the assignment you just described you should be able to avoid
any of these.) Use standard library containers such as std::vector and
std::string rather than their C language counterparts.

Good luck.

--
Cy
http://home.rochester.rr.com/cyhome/
Jul 22 '05 #3

"SB" <vo******@hotmail.com> wrote in message
news:u0d_b.14387$Dc2.7710@lakeread01...
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment that is basically a doctors scheduling program, i.e. for three doctors show their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.

Thanks in advance!


A common piece of advice is that the nouns are classes and the verbs are
methods.

So on that basis I would say the only dead certs for classes are Doctor.
Some methods on Doctor would be book_surgery, book_lecture, print_schedule,
make_appointment.

Some possibles for classes would be Patient, TimePeriod, Schedule, but from
the description above I don't think I would use any of those.

john
Jul 22 '05 #4
There are a lot of factors that you need to consider (or if your
assignment is as flaky as most of the ooa&d classes we used to have
forced upon us, make up and state your own constraints, then defend
them). I would probably start by looking at the largest and smallest
discrete time segments. Those are probably going to make good
classes. Do visits ever stretch between months? Probably not, so a
month might be a good container class (espescially since it is
mentioned in your assignment and it is convenient for fiscal etc
analysis). On the other end of the time spectrum... do doctors always
allocate the same amount of time for each visit? Are there
constraints, such as limited waiting areas or observation rooms or
whatever? Do we have to consider medical histories or lab usage when
scheduling patients? These concerns are also going to shape your
modelling. Assuming the office keeps regular hours and your only
constraint is time, then you are probably going to want month, day,
and scheduled_visit objects for each doctor with doctor as either an
enumerated type or a part of a global wrapper class.

hope this got your juices flowing.

"SB" <vo******@hotmail.com> wrote in message news:<u0d_b.14387$Dc2.7710@lakeread01>...
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment
that is basically a doctors scheduling program, i.e. for three doctors show
their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.

Thanks in advance!

Jul 22 '05 #5
SB wrote:
Can anyone provide any insight/advice on how to take a problem (academic
assignment) and figure out what the classes should be? I have an assignment
that is basically a doctors scheduling program, i.e. for three doctors show
their schedule for the month of surgies, lectures and free time. It also
lets patients schedule appointments in the free time slots.
My problem is not being able to determine what the classes and how many of
them there should be. I know this is open ended, as each programmer might
see it differently and have different classes and not the same number of
classes as the next programmer. I would just like to know if there are any
guidelines to follow for breaking a problem down into classes.

Thanks in advance!


If you're really eager, I suggest you research on "use cases".
Use Cases are a tool to help extract the requirements out of
a problem domain.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #6

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

Similar topics

13
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes....
13
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes....
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
43
by: Tony | last post by:
I'm working with GUI messaging and note that MFC encapsulates the message loop inside of a C++ class member function. Is this somehow inherently less robust than calling the message loop functions...
6
by: JoeC | last post by:
I have a question about designing objects and programming. What is the best way to design objects? Create objects debug them and later if you need some new features just use inhereitance. Often...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.