[Tutor] class design

Kent Johnson kent37 at tds.net
Sat Jun 6 13:02:05 CEST 2009

On Sat, Jun 6, 2009 at 5:04 AM, Norman Khine<norman at khine.net> wrote:
> Hello,
> I would like help to design the following:
> http://paste.lisp.org/display/81448

Product.get_days() may have a bug, it only returns the first container it finds.

You probably don't want the view code in the same class with the data.
It's generally a good idea to separate the model - the representation
of data - from the view - the display of the data.

The get_images() methods are all very similar. If each class had a
get_children() method then you could combine the get_images(). For

class Product(Folder):
  def get_children(self):
    children = [ self ]

class Folder(object):
  def get_images(self):
    images = []
    for child in self.get_children():
    return images

You might be able to do something similar with get_days().

I wonder why you are not using a database to store all this? I can't
help wondering what the code would look like in Django.


More information about the Tutor mailing list