[Tutor] Design Question...

Alan Gauld alan.gauld at btinternet.com
Fri Jun 1 20:12:34 CEST 2007

<dsh0105 at comcast.net> wrote

> I'm doing the initial design for what will (hopefully) be something
> like a flash-card system. This is mostly a learning exercise,
> but I'm hoping the results will be at least usable.
> So my question is does this class design shown
> by the psudo-code below sound reasonable?

It depends on what other classes exit however some quick

> class Deck(Questions):

It ingherits from Questions - which is an odd name for a class,
they are usually singular. But...
Is a deck a type of Question? I'd expect it to be a kind of list
or maybe a stack (but Python lists support push/pop methods)

>    """"Contains a set of questions, and provides information
>         and utility functions for them

The questions should contain any utility functions that operate
on the question itself. but the deck should control the questions
as a group.

>          methods:
>          add_question(Question) -- Ads a question to the deck
>          get_next() -- Returns the next question in the deck

These look reasonable. How will the questions be sorted?
Will it be first in first out? Or last in first out?
Or is there a sorting criteria? If so does it need to
be modifiable? If so you might like to create an internal
method for sorting that can be hooked with a comparison
How do you hold the current position so you know where
next is?

These are all design questions to think about.

But fundamentally your Deck interface looks good.

Other interfaces you might consider:

search for a question (by what key?)
count the questions - total, unasked, asked etc?

Without knowing much about the rest of the system - and only
a vague concept of what a flash card is - I can't say much more.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list