Class hierarchy design question 
Author Message
 Class hierarchy design question

I've designed a few class hierarchies, and usually find them decently
coherent and logical.  Sometimes even very good.  However, one of them,
maybe the smallest (it's just three classes), really distresses me...

(suspence)

It is the Namespace class hierarchy for GNU Smalltalk, which dates to
about one year ago.  I still hate the solution I contrived, yet I cannot
think of a better one; here it is:

(more classes here...)
   Dictionary
      RootNamespace
         Namespace
         SystemDictionary

Too much implementation-revealing. Heck, it should be obvious that the
Smalltalk SystemDictionary is a root namespace, but a root namespace
should be *more* specialized than a non-root namespace!

Kent Beck says something like `subclass names usually add an adjective
that specifies what's the difference from the superclass' -- e.g.
SequenceableCollection vs. Collection, SmallInteger vs. Integer.  This
hierarchy does the opposite (SystemDictionary has that name for historical
reasons -- of course today I'd call it SmalltalkNamespace).

The reason is, RootNamespace adds to Dictionary the machinery for handling
the namespace hierarchy, while Namespace adds to RootNamespace the
machinery for looking up identifiers in super-namespaces if the receiver
does not contain the key... on the implementation level this surely saves
a lot of lines of code, and that's indeed part of what inheritance is
supposed to do.  But it's also supposed to show generalization-specification
relationships, and this simple three-class hierarchy fails completely with
respect to this.

What do you think, oh Smalltalk mavens in cls?

Paolo Bonzini

|_  _  _  ___
|_)(_)| )  ,'
--------- '-._.

--
Posted from ccrd200.cdc.polimi.it [131.175.6.2]
via Mailgate.ORG Server - http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 Class hierarchy design question
In article

| The reason is, RootNamespace adds to Dictionary the machinery for handling
| the namespace hierarchy, while Namespace adds to RootNamespace the
| machinery for looking up identifiers in super-namespaces if the receiver
| does not contain the key... on the implementation level this surely saves
| a lot of lines of code, and that's indeed part of what inheritance is
| supposed to do.  But it's also supposed to show generalization-specification
| relationships, and this simple three-class hierarchy fails completely with
| respect to this.

Is it just that the name "RootNamespace" implies a specialization of
Namespace (which it isn't)?  Have you tried other names for it (like
"Class" is a specialization of "Behavior")?

--

     -- Tim Olson



Wed, 18 Jun 1902 08:00:00 GMT  
 Class hierarchy design question

Quote:
> Is it just that the name "RootNamespace" implies a specialization of
> Namespace (which it isn't)?

Yes.

Quote:
>  Have you tried other names for it (like
> "Class" is a specialization of "Behavior")?

I could not find any...

Paolo

--
Posted from relay1.inwind.it [212.141.53.67]
via Mailgate.ORG Server - http://www.Mailgate.ORG



Wed, 18 Jun 1902 08:00:00 GMT  
 Class hierarchy design question



Quote:
> > Is it just that the name "RootNamespace" implies a specialization of
> > Namespace (which it isn't)?

> Yes.

   Dictionary
      NamespaceAbstract
         RootNamespace
         Namespace
         SystemDictionary

If that is all you're worried about.

But the issue is more interesting than that, isn't it?



Wed, 18 Jun 1902 08:00:00 GMT  
 Class hierarchy design question

Quote:
>   Dictionary
>      NamespaceAbstract
>         RootNamespace
>         Namespace
>         SystemDictionary

SystemDictionary would be a subclass of RootNamespace. I am surprised I
didn't think of that... maybe it is because I don't like the
`NamespaceAbstract' name. What about...

      Namespace
         RootNamespace
         ChildNamespace

This looks good to me.

Thank you! A small issue, but it was slowly eroding my mind ;-)

--
|_  _  _ __
|_)(_)| ) ,'
-------- '-._

--
Posted from relay2.inwind.it [212.141.53.73]
via Mailgate.ORG Server - http://www.Mailgate.ORG



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. newbie question, MY classes in the hierarchy

2. Question: Querying Class Hierarchies

3. hierarchy extraction from verilog designs

4. VHDL Design Hierarchy

5. Design question - Internals of a Command class

6. Design Question: Module -vs- Class Methods

7. dbi and class design question

8. Question about class design

9. Design question.... parent/child class

10. Design question: HotDraw classes Figure & Drawing

11. How to print class hierarchy diagram?

12. Class hierarchy

 

 
Powered by phpBB® Forum Software