newbie architecture question

J

Joe Poniatowski

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?

Jp
 
A

Aahz

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?

Class definitions should *NOT* be nested.
 
D

Dang Griffith

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.

--dang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,478
Latest member
ReginaldVi

Latest Threads

Top