[Tutor] When to Chop Suey...
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 28 Jun 2001 17:09:17 +0100
> I am writing a med sized program and I'm wondering if anyone
> has advice on when to chop off a bunch of classes from my
> main module and put it in another one?
Generally I always put class definitions in separate modules to
the main program. That way I can reuse the classes and the main
program just creates some objects and uses them.
As to how many classes per module I suggest that mutually dependant
classes go in the same module - thus if you can't create an A without
also having to create a B keep A and B together. As somebody famous
said (Robert Martin?) "the unit of reuse is the category" which is a
reference to the old Booch notation for a group of classes that work
together. Categories in Booch translate to modules in Python.
Alan G