No Hungarian Notation in Smalltalk
Joel Shellman
joel at ikestrel.com
Wed Nov 5 00:02:05 UTC 2003
Doug Way wrote:
> I agree 100% that we don't need to have prefixes and suffixes in
> base-image class names for namespace reasons.
>
> However, some suffixes are arguably useful as simply a more
> descriptive class name, even if they might be a bit redundant with
> regard to a superclass name. For example, BorderedMorph is a subclass
> of Morph. You could argue that it should just be called Bordered, but
> that seems less readable to me. I think of it as a "bordered morph",
> not just a "bordered". (A noun suffix (e.g. "Morph") is especially
> helpful if the class would otherwise not be a noun (e.g. "Bordered").)
>
> So in that sense, perhaps Roel's naming of classes with an "Event"
> suffix is perfectly fine.
>
> - Doug
Perhaps the difference is when there is no noun. "Bordered" might be
less desirable because it is an adjective and not a noun. It would be
hard to say that "Bordered" is an "object". It's hard to be an object
without a noun.
So, perhaps the heuristic is avoid suffixes/prefixes in general. If
there is no noun available, you can use one. However, one might want to
consider very carefully if there isn't an appropriate other noun to use.
Another difference regarding "BorderedMorph". That is obviously a simple
decorator. Whereas, if you had a morph in the shape of a Star or Flower,
one could argue that these should not be suffixed with Morph. And
then... let's say someone makes a Star with a border, BorderedStar would
make sense for a name.
It seems what I'm arriving at is that the ones I'm thinking might be
justifiably have a suffix are ones that refer to classifications:
BorderedMorph is a classification of Morphs, but does not necessarily
refer to a specific kind of morph. Ie. it's intention is not to be a
leaf of the inheritance hierarchy, but rather to be subclassed just like
the original Morph.
So here's a hierarchy structure:
Entity -> PhsyicalEntity -> Being -> CarbonBasedBeing -> Human
->FunnyHuman -> Comedian ->ProfessionalComedian
What I notice is that you keep adding adjectives until you have changed
into a new category of things. (Interesting side note, seems to me the
adjective is a sign that it could use a trait to implement that decoration.)
Hmm.... I think I see another difference, events and exceptions are
predicate (or at least include a predicate):
Exceptions:
DivideByZero
DoesNotUnderstand
ObjectIsUndefined
TargetServiceIsUnavailable
Events:
YourSmellySocksGotWashed
DatabaseShutDown
In that way, the prefix/suffix would be redundant. If it's a predicate,
you know it's an "event". And an exception is just an exceptional event
in a way after all. In fact, I'm having difficulty not using past tense
or present participle for events. Is that wrong?
Sorry for my rambling, I hope it was useful. There are probably proper
technical terms for much of this but I'm not properly schooled in them.
-joel
More information about the Squeak-dev
mailing list
|