[Tutor] my first object model, using an interface

Alan Gauld alan.gauld at btinternet.com
Sun Jul 6 10:19:02 CEST 2008

<tpc247 at gmail.com> wrote

> adequately, after reading Alan Gauld's excellent tutorial

Thanks for the mention, glad you found it useful.

> - a Watchable interface that, when implemented, signifies that the
> implementing object has a threshold and associated package.
> - a Package class, that can be seen as a container for courses 
> and/or one
> part of a course
> - a Course class, that can be seen as a container for gradable 
> homework
> - a Homework class, that has a flag to indicated whether it has been
> received by the school
> - most Packages are Watchable (except the last Package object), and 
> only one
> or two Courses in a Package need to be Watchable

OK, I'd consider whether you really need all those containers.
Python comes with lots of conrtainer options built in, maybe
simple lists and dictionaries would suffice?

Secondly you are thinking too much about the data. You do
not mention the behaviour of these classes at all.

Go back and describe your classes again but in terms of the
behaviours that they exhibit. What is each class's responsibilities.
What do they do within the program. You might get a smaller
list of classes. I suspect maybe only 2 plus some Python
containers are all thats needed.

I don't have time to do a detailed analysis but my gut feel is
too many data driven classes. And way too many getXXX/setXXX
methods. Python is not Java.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list