newbie architecture question
noemail at noemail4u.com
Thu Dec 18 19:32:25 CET 2003
On Fri, 12 Dec 2003 08:35:39 -0500, "Joe Poniatowski"
<jponiato at ford.nospambot.com> wrote:
>I wish to define a hierarchy of classes - something like book, chapter,
>page, where books are made of one or more chapters, and chapters consist of
>one or more pages. Should the definitions be nested, or all at the module
>level with just the instantiations nested?
That sounds more like a hierarchy of containers, rather than a
hierarchy of classes. A class hierarchy is used when the "is-a"
relationship is always true. A book is not a chapter is not a page.
Given that, they should be defined at the same level (or at least
*not* nested), and then instances of one can contain instances of the
other. E.g., a book object can contain instances of chapter objects,
which can contain instances of page objects.
More information about the Python-list