[squeak-dev] conceptual help please
Chris Cunnington
smalltalktelevision at gmail.com
Wed Sep 12 01:24:48 UTC 2012
On 12-09-11 9:02 PM, Joseph J Alotta wrote:
> I think it would be like this:
>
> A (1) Family has (2) Clients who have (3) Accounts each having (4) Folios which contain (5) Securities.
>
> Should I implement this directly in a class hierarchy, even though each class is very different from the parent class?
I gave advice yesterday and got it backwards, but I figure I'll try
again anyway.
I think you're answering your own question by saying "even though each
class is very different from the parent". Doesn't sound like inheritance
much, does it? Inheritance hierarchies start general and get more
specific as they go down. Automobile --> car --> sedan --> Chevrolet -->
Impala.
Your five objects don't sound like they descend with increasing
specificity. They do form a tree diagram in that they become more
numerous as you descend. Your hierarchy is a "part-of", aggregation,
whole-part, composite, or "has-a" hierarchy. (Thank you Chamond Liu from
pg. 21 of "Smalltalk, Objects, And Design".
http://www.amazon.com/Smalltalk-Objects-Design-Chamond-Liu/dp/1583484906
). You start with one family and you end with it having many, many
securities. The difference between inheritance and composition is a
large topic, but this could be a start:
http://en.wikipedia.org/wiki/Has-a
I can't say how you'd design your application, but it sounds like you
already know inheritance won't be the relationship of those classes.
Hope That Helps,
Chris
More information about the Squeak-dev
mailing list
|