[Tutor] Structuring a class
Alan Gauld
alan.gauld at btinternet.com
Tue Jun 15 09:44:15 CEST 2010
"Lang Hurst" <lang at tharin.com> wrote
> I'm trying to figure out how to deal with data which will look
> something like:
>
> Student:Bob Hurley
> Credits:
> Algebra C (20P)
> Chapter 1
> Chapter 2
> Consumer Math (24G)
> Module 2
>
> So, I just figured that I would have a couple of nested
> dictionaries.
Or 3 classes: Student, Credit, Module
But classses will be most useful if you are doing a lot of
interaction between the students or calculations based on the credits.
As Bob suggested, if you mainly just want to add/delete/modify
and report on the data a database is a better bet.
You mght still create a Student class to structure the data
coming back from the database but the other classes will
probably be overkill and your double dict will be as effective.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list