Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > class design question

Reply
Thread Tools

class design question

 
 
SB
Guest
Posts: n/a
 
      02-23-2004
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!


 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      02-23-2004
* "SB" <> 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++].

 
Reply With Quote
 
 
 
 
Cy Edmunds
Guest
Posts: n/a
 
      02-23-2004
"SB" <> 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/


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      02-23-2004

"SB" <> 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


 
Reply With Quote
 
anon luker
Guest
Posts: n/a
 
      02-23-2004
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" <> 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!

 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      02-23-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class design/ design pattern question Bartholomew Simpson C++ 2 06-12-2007 08:51 PM
class design vs. db design John_Woo Java 2 12-19-2006 08:27 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM
Class design/design pattern resources TomTom MCSD 2 10-09-2004 07:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57