473,385 Members | 1,402 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,385 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 1970
* "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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.