Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: The joys of bad code

by 5p1d3r (Hermit)
on Oct 26, 2004 at 12:42 UTC ( #402552=note: print w/replies, xml ) Need Help??

in reply to The joys of bad code

Not really bad, but funny. I've seen a bit checking routine written by "John" with the misfortunate function name johnbitchk(). In the same source file as the above we have the following:
some_really_long_type_name *myArray = NULL; /* so we dont have to type that horrible variable name */ myArray = global_pooled_child_array;
myArray is used exactly once in the following code.

Replies are listed 'Best First'.
Re^2: The joys of bad code
by stvn (Monsignor) on Oct 26, 2004 at 14:39 UTC

    I never really understood the whole "I dont want to have to type a long variable/package/class name" school of thought/excuses. Most programmers I know are pretty fast typers and it seems to me that it is worth the upfront time to craft well written code with clear and understandable variable/package/class names. IMO, using short names is the wrong kind of laziness.


      Same reason really good note-takers develop a shorthand. It's just faster that way.

      Abbreveations are generally good when they're well-choosen, but poorly-choosen ones suck the big one.

      IBM midrange systems are riddled with bad abbreveations. Could you tell me what a file named "HREMFP" is supposed to have in it? This is an actual file name in a beginners book for midrange programmers/admins that I was given. (And trust me, the name isn't clear from any of the context in the surrounding chapter, either). They love to keep to about 6 characters per file name, weather it could be made shorter or needs to be longer.

      Part of this is technical limitations of the platform, but the limitations seem to be so ingrained in the midrange community that I doubt people would start using sane naming standards even if the technical problems went away.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      TheLongerTheNameIsTheMoreLikekyYouMakeATypo. Of course you should be using strict, but that will not help you with subroutine names in Perl. Both having the names too short and too long is wrong IMHO. Now the question is what the right length is ;-)

      We'd like to help you learn to help yourself
      Look around you, all you see are sympathetic eyes
      Stroll around the grounds until you feel at home
         -- P. Simon in Mrs. Robinson

      I agree.

      To the folks who say that long names are slower to type, or easier to misspell, please do everyone a favor and get a better editor. I don't care which one, but almost all of the good ones have some form of abbreviations or completions. Start typing an identifier, and let the editor suggest the rest of the word for you. One third of the typing, or two hundred percent improvement in readability, depending on your point of view.

      [ e d @ h a l l e y . c c ]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://402552]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2018-05-22 14:25 GMT
Find Nodes?
    Voting Booth?