[Prev][Next][Index][Thread]

Re: Long names are doom ?



I could not resist this. In Smalltalk, you can find for example the longest
class name by the following code fragment. The code can be shortened, but this
version shows very clearly what happens. I think that even a non-Smalltalk
person can se what is going on - partially because of names that programmers in
other languages might consider too long.

| longestName maxLength |
longestName := ''.
maxLength := 0.
Object withAllSubclasses do:
 [:class | | newName newLength |
  class isMeta
   ifFalse: [
  newName := class name.
  newLength :=  newName size.
  newLength > maxLength
    ifTrue: [longestName := newName. maxLength := newLength]]].
longestName

By the way, the answer is ... (left as an exercise).

Ivan

Jochen Schmidt wrote:

> 00001111 wrote:
>
> >  Hi All,
> >
> >   Anybody use variables/names longer than 31 character
> > and finds it really useful ?
>
> Yes. In Common Lisp long identifiers are often used.
>
> Take a look in
> "The Art of the Metaobject Protocol"
> to see identifiers like:
>
> generic-function-argument-precedence-order
> update-instance-for-different-class
> ensure-generic-function-using-class
>
> and I've to say it is _good_ that they are so long.
> Yes you could e.g say
>
>   genFunArgPrecOrder
>
> But it is *much* less readable this way.
>
> > Then please respond  why, where, when.
> > I have folks here in comp.lang.fortran who claim hard that they
> >
> > - "never seen a well written, legible program
> >   that uses any identifiers longer than 18-20 characters..".
>
> Nonsense
>
> > - "long variables names are *hard* to read.  And, you have to
> >   read though all the characters of every instance of them...".
>
> see above Example "genFunArgPrecOrder"
>
> > - "it degrades the legibility of a program to use identifiers that
> >   can't be easily remembered...."
> >
> > As a result, despite 90% of computer languages have long, very
> > long or 'infinite' identifiers, fortran folks seems plan to stay
> > with their 6...aargh ...sorry this was just not far ago... 31 character
> > limit intil year 3000.
>
> 6 characters? so my example would be like gFuAPO - yes _very_ readable!! ;-)
>
> Regards,
> Jochen




Follow-Ups: References: