[Tutor] OOP design (w/ example :-)

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 24 Mar 2001 20:10:14 -0800 (PST)


On Sat, 24 Mar 2001, Sheila King wrote:

> FYI: I use a deck of cards. If I have 24 students present, and I want
> groups of four, I choose all the cards Ace through six, shuffle them,
> and go around having the students each draw one card. Then everyone
> who drew an Ace forms one group, all the twos form another group, and
> so on. If I want them in pairs, then the two red Aces are a pair, and
> the two black Aces are a pair, and so on. Obviously, this doesn't
> ensure gender mixing and so on. And I like the idea of your little
> program very much. Heh, if you get it working, I wouldn't mind a copy,
> myself.

There was a small discussion on shuffling, by the way, on the Edu-Sig
mailing list a while back... *grin*:

    http://mail.python.org/pipermail/edu-sig/2000-November/000772.html

I'm not quite sure how it would handle gender mixing either.  One solution
would be to shuffle people around, and then try to divide people into
groups.  If it's not mixed "well", according to some heuristic measurement
of "wellness", toss out the result and try it again.  So the pseudo-code
would be something like:

###
while 1:
    mixed_people = shuffle(people)
    split_groups = splitUpTheGroupsEvenly(mixed_people)
    if goodDistribution(split_groups): break
###


> :I'd like to try a OOP approach, but one of the things I struggle with is the
> :initial design stage. I've asked about this before and I've done some
> :reading, but I still haven't found a way of thinking about problems like
> :this that make a lot of sense to me.

Subjective comments: I like the decomposition of lines of text into a list
of Students.  I don't think it's too necessary to take the OOP any
further, since normal Python lists should be able to handle groups fairly
well.  Another recommendation: don't force OOP into your design if it
doesn't fit well.