13.07.2015 Views

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

Smalltalk Best Practice Patterns Volume 1: Coding - Free

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Simple Superclass NameWhat should you call a class that is expected to be the root of an inheritance hierarchy?All naming decisions have several constraints in common. You want names that are as short aspossible, so they are easy to type and format and say. At the same time, you want to convey asmuch information as possible in each name, so readers will not have to carry as much knowledge intheir heads. You want names that are familiar, to take advantage of knowledge readers already havevia metaphor or analogy. However, you want names that are unique, so that others who are alsochoosing names will not accidentally choose names that interfere with yours.The first rule I follow is no abbreviations. Abbreviations optimize typing (a 10-100 times in 20years task) over reading (a 1000-10000 times in 20 years task). Abbreviations make theinterpretation of a name a two step process- what do the letters stand for and then what do thosewords mean. The class and method naming patterns here will produce names that you should neverhave to abbreviate.Naming the root class of a large hierarchy is a momentous occasion. People will be using the wordsyou choose in their conversation for the next 20 years. You want to be sure you do it right.Unfortunately, many people get all formal when they go to name a superclass. Just calling it what itis isn’t enough, they have to tack on a flowery, computer science-y, impressive sounding, butultimately meaningless word like Object, Thing, Component, Part, Manager, Entity, or Item.You’re creating a vocabulary, not writing a program. Be a poet for a moment. The simple, thepunchy, the easily remembered will be far more effective in the long run than some long name thatsays it all, but in such a way that no one wants to say it at all.Name a superclass with a single word that conveys its purpose in the design.There are lots of good examples in the image:NumberCollectionMagnitudeModelYou may create variations on this class, each with a Qualified Subclass Name.<strong>Coding</strong> <strong>Patterns</strong> page 123 of 147 9/30/2006

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!