Re: classes and inheritance revisited
"John T" <printdude1968@gmail.com> wrote in message
news:s%%Ah.6824$R71.102443@ursa-nb00s0.nbnet.nb.ca...
"Alex Hunsley" <redlex@bluebottle.com> wrote in message
news:45d48861$0$759$5a6aecb4@news.aaisp.net.uk...
I would just like to chime in here to say some design decisions can be
made more easily if you have some sort of idea of how your class
hierarchy is going to be used in the end.
For the moment, it seems you're designing a hierarchy without much idea
yet of how these classes would be used. (Please forgive me if I've missed
somewhere where you gave an idea of how these classes might be used!) To
a certain degree, you can make up example scenarios, but having some 'how
will I be using these classes?' concept in mind can help guide you.
lex
This is an educational experience for me. I am making my way through some
of the more popular books on Java Programming and am trying to put what I
learn into practice with real-world scenarios. My initial thought was to
model the Animal Kingdom, but that proved a bit too ambitious. Then I
toyed around with the idea of modelling a military structure. But that
proved to difficult to nail down. So I went back to my initial idea, but
decided to start out small, with a few classes which I had identifed as
being at the bottom of the hierarchy.
If you're trying to model the animal kingdom, then I wouldn't have
classes like "Cat", "Tiger", "Deer", etc. because you wouldn't actually have
cats, tigers or deers in your model. Rather, you would have the concept of
the species called "cat", the species of the concept called "tiger", the
concept of the species called "deer" and so on.
I.e. you're not modeling individual cats, but the concept of a cat
itself. Thus your classes might be Phylum, Order, Family, Genus, etc.
Alternatively, maybe you *do* want to model a bunch of cats running
around and mewling. In which case, you're not modeling the animal kingdom,
but rather a bunch of cats (or other animals) doing whatever it is that
those animals do.
Perhaps some of the confusion is arising because you haven't decided
which between these two alternatives you're going for.
- Oliver