Comment On theInfamousI and The Responsible Guy

Instead of looking at bad code today, I think it'll be fun if we look at bad coders. Well, I mean, not at their pictures or anything, but look at their code. But not their bad code, just the code that makes 'em ... err ... bad. Ugh. My explanation obviously isn't working, so lets just dig right in ... [expand full text]
« PrevPage 1 | Page 2Next »

kind of off subject, still bad

2005-03-24 14:30 • by SomeGuy
This reminds me of a time when a buddy of mine was turning in code for a project in our Machine Learning class. He was getting frustrated with the code one night and put in a comment along the lines of:

//Instantiates your Mom

Our instructor, a man with a good sense of humor wrote a comment on the returned code going something like "Good work on the project, and my mother will be happy to know she has finally been instantiated.

Re: kind of off subject, still bad

2005-03-24 14:54 • by rogueRPI
31757 in reply to 31753

Do people expect this kind of thing to work?


Unless that perl script had a LOT more random subjects and bodies, I'd get suspicious after a week or two when they started repeating (complete with typos).


How lazy do you have to be that you can't even write a new email every day?

Re: theInfamousI and The Responsible Guy

2005-03-24 15:03 • by cm5400

The function names are hilarious!  I especially like WhosYourDaddy(node). Go Pedro!  [:D]

Re: kind of off subject, still bad

2005-03-24 15:05 • by Sumit
31759 in reply to 31757
I would still give the guy points for ingenuity.

Re: kind of off subject, still bad

2005-03-24 15:07 • by Brian
31760 in reply to 31757
I never actually saw the emails, but I was suspicious when the manager in charge of catching this years ago repeatedly said the developer in question wouldn't make it to the meeting because he was watching the emails go out.

Yeah right. :P I guess that speaks volumes about the manager, also.

But did he get away with it? Yes. Well, until now. :)

Re: kind of off subject, still bad

2005-03-24 15:13 • by dubwai
31761 in reply to 31760

Anonymous:
But did he get away with it? Yes. Well, until now. :)


That takes some pretty big balls.  I mean, if this is pretty important and he's not really watching the 'emails go out' (WTF?), what if something went completely wrong?

Re: theInfamousI and The Responsible Guy

2005-03-24 15:29 • by Steven
I don't think I would call this person a bad coder. He's a lazy sneak,
yes, but the idea is ingenious enough. Also, the other "interesting
findings" aren't really WTFs, are they? Just shows that some coders
have a sense of humour.

Re: theInfamousI and The Responsible Guy

2005-03-24 15:35 • by dubwai
31765 in reply to 31764

Anonymous:
I don't think I would call this person a bad coder. He's a lazy sneak, yes, but the idea is ingenious enough. Also, the other "interesting findings" aren't really WTFs, are they? Just shows that some coders have a sense of humour.


You might want to re-read the intro.  Also, naming your methods and variables jokey names is WTF.  Try staying up late trying to debug code with no comments and useless variable and method names and contextless debugging that includes commentary on completely usesless aspects of the process and you'll understand.

Re: theInfamousI and The Responsible Guy

2005-03-24 15:37 • by loneprogrammer
31766 in reply to 31764
Steven:
the other "interesting
findings" aren't really WTFs, are they? Just shows that some coders
have a sense of humour.


Can you figure out WTF RiceCrispies(Snap(Crackle(Pop()))) is supposed to do?



I'm not able to see the humour in it when I'm trying to figure WTF is
going on, the code is crashing, and the customer needs it fixed *yesterday*.

Re: theInfamousI and The Responsible Guy

2005-03-24 15:51 • by mxksweeb
I am *so* using theInfamousI++ as my default incrementer from now on!!

Re: theInfamousI and The Responsible Guy

2005-03-24 16:08 • by diaphanein
31770 in reply to 31769

My favorite comment from my school days (from my own code) was:


// was drunk...will fix later.


This comment was followed by a string of variable names containing expletives.  Amazingly, despite being drunk, the code worked.  Just had to rename the variables before submission. 

Re: theInfamousI and The Responsible Guy

2005-03-24 16:13 • by Pragma
31771 in reply to 31766
loneprogrammer:
Steven:
the other "interesting
findings" aren't really WTFs, are they? Just shows that some coders
have a sense of humour.


Can you figure out WTF RiceCrispies(Snap(Crackle(Pop()))) is supposed to do?



I'm not able to see the humour in it when I'm trying to figure WTF is
going on, the code is crashing, and the customer needs it fixed *yesterday*.





I think the obligatory first step is: "What do your RiceCrispies() say to you?"



It reminds me of when I was helping out other students in my
High-School CS class all those years ago.  One fellow had a pascal
program with variable names like 'a', 'x', 'n' and so on.  I
suggested that he use "real names" instead of "just letters".  He
then showed me his revised code with names like "Shaq", "Jordan",
"Pete", "Alex" and so on. :'(

Re: theInfamousI and The Responsible Guy

2005-03-24 16:20 • by BradC
31773 in reply to 31771

Anonymous:
It reminds me of when I was helping out other students in my High-School CS class all those years ago.  One fellow had a pascal program with variable names like 'a', 'x', 'n' and so on.  I suggested that he use "real names" instead of "just letters".  He then showed me his revised code with names like "Shaq", "Jordan", "Pete", "Alex" and so on. :'(


hehe. As you are walking away, he's probably thinking


"real names.... real names, WHY should I put REAL names in my code? Well, I guess he knows better."


This is especially tough for people coming to programming from mathematics. In mathematical equations, if you see "ax + by", a, x, b and y are separate variables. In programming, you're just adding two variables. Oddly names ones, but still, just two.

Re: theInfamousI and The Responsible Guy

2005-03-24 16:21 • by WTFPhenom
31774 in reply to 31769
What language do YOU use that you can use ++ in your identifier name?  I'm a Microsoft guy and I truly don't know the answer to that because MS languages don't allow it.

Re: theInfamousI and The Responsible Guy

2005-03-24 16:23 • by BradC
Ok, we need to see the ascii image of Trogdor! A google search didn't find anything useful!

Re: theInfamousI and The Responsible Guy

2005-03-24 16:25 • by BradC
31777 in reply to 31774

Anonymous:
What language do YOU use that you can use ++ in your identifier name?  I'm a Microsoft guy and I truly don't know the answer to that because MS languages don't allow it.
I think he just meant that the variable was "theInfamousI". He didn't say it that way, but I also can't imagine any language that would support that as a legal variable name.

Re: theInfamousI and The Responsible Guy

2005-03-24 16:34 • by SOS
31778 in reply to 31777
Haha, I love those var/func names [:D] Cool going! Great to brigten up some boring code

Re: theInfamousI and The Responsible Guy

2005-03-24 16:39 • by JamesCurran
31779 in reply to 31773
BradC:
"real names.... real names, WHY should I put REAL names in my code? Well, I guess he knows better."

This is especially tough for people coming to programming from mathematics. In mathematical equations, if you see "ax + by", a, x, b and y are separate variables. In programming, you're just adding two variables. Oddly names ones, but still, just two.


Reminds me of something I did in College for a class project.  Essentially, just the reverse.


It was to process some mathematical algorithm, so I kept the simplic variable names of the original.  (One was just "X", and there was a pointer called "ptr").


To document it, a wrote a short story -- a spoof of Sherlock Holmes --- which explained how it worked.  There was a "Mysterious Mr. X" and a dog named "Ptr".  (If I recall correctly, it was called "The Strange Case of Polly Nomial")


I probably still have the listing somewhere......


(Oh, and I got an "A" on it.....)


 


 

Re: theInfamousI and The Responsible Guy

2005-03-24 16:42 • by Sweets
Awesome, never again do I have to stay late at work looking at pron, pretending I'm working.  Y

Re: theInfamousI and The Responsible Guy

2005-03-24 16:44 • by Andy Lester
I can't believe I'm correcting WTF code, but what he wants is not



@titles[rand($#titles)]



but rather



$titles[rand @titles]



In a 10-element array, @titles is 10, but $#titles is 9.  He'll always miss the last option.

Re: theInfamousI and The Responsible Guy

2005-03-24 16:49 • by mxksweeb
31782 in reply to 31779
JamesCurran:
Reminds me of something I did in College for a class project.  Essentially, just the reverse.

It was to process some mathematical algorithm, so I kept the simplic
variable names of the original.  (One was just "X", and there was
a pointer called "ptr").


To document it, a wrote a short story -- a spoof of Sherlock Holmes
--- which explained how it worked.  There was a "Mysterious Mr. X"
and a dog named "Ptr".  (If I recall correctly, it was called "The
Strange Case of Polly Nomial")


I probably still have the listing somewhere......




(Oh, and I got an "A" on it.....)





That is *awesome*!! I am writing all documentation in the form of prose
from now on!  I'm glad you got an A on it too--shows the
instructor valued creativity (a good skill in programming) as well as
proficiency.

Re: theInfamousI and The Responsible Guy

2005-03-24 16:57 • by Kippesoep
31783 in reply to 31766
loneprogrammer:


Can you figure out WTF RiceCrispies(Snap(Crackle(Pop()))) is supposed to do?





Not without seeing the code, admittedly, but there is no context here.
In the real code there may actually be comments there. As it is, it's
funny.

Re: theInfamousI and The Responsible Guy

2005-03-24 17:06 • by Top Cod3R
One thing I like to do when naming my local variables is to prefix them with the function name, something like this:

Public Sub MyRiceCrispies( )
   Dim MyRiceCrispies_I As Integer
   Dim MyRiceCrispies_X As String
   ...
End Sub

This way you always know what function they came from, and it also helps the compiler optimize your code, making it less likely to confuse them with variables from another function.

Anyone else have any variable naming tips they'd like to share?

Re: theInfamousI and The Responsible Guy

2005-03-24 17:07 • by Kippesoep
31785 in reply to 31765
dubwai:

Try staying up late trying to debug
code with no comments and useless variable and method names and
contextless debugging that includes commentary on completely usesless
aspects of the process and you'll understand.





You're describing my very job. (Well, actually, you forgot to add one
thing: do this on a live system that allows for maintenance only
between 1 and 5am)



At least there is a reason behind many of the variable/function names mentioned ("WhosYourDaddy", for instance). Try the ones I have to deal with:


  • kurvakeves

  • naakkoridajigeljutott

  • namostfoghivni

  • nasikerultis



Re: theInfamousI and The Responsible Guy

2005-03-24 17:13 • by Gooch
31786 in reply to 31777
Perl will quite happily allow you to declare $theInfamousI as a variable, and then increment it via

$theInfamousI++



ex: $theInfamousI=0;

$theInfamousI++

print "$theInfamousI\n";   -> will print out "1"..



 I'd have to suspect that's what was really going on with that little gem.

Re: theInfamousI and The Responsible Guy

2005-03-24 17:15 • by Moi
31787 in reply to 31766
loneprogrammer:


I'm not able to see the humour in it when I'm trying to figure WTF is
going on, the code is crashing, and the customer needs it fixed *yesterday*.





You don't know the context. Way to get yer panties in a bunch. A little humour in a small scope is hardly a maintenance issue.

Re: theInfamousI and The Responsible Guy

2005-03-24 17:20 • by fool
31788 in reply to 31758
my favorite was in some code a friend wrote that had the whitespace-trimmer KillWhitey()

Re: theInfamousI and The Responsible Guy

2005-03-24 17:28 • by dubwai
31789 in reply to 31785
Kippesoep:
At least there is a reason behind many of the variable/function names mentioned ("WhosYourDaddy", for instance). Try the ones I have to deal with:


  • kurvakeves
  • naakkoridajigeljutott
  • namostfoghivni
  • nasikerultis

Is that Swedish or something?

Re: theInfamousI and The Responsible Guy

2005-03-24 17:30 • by dubwai
31790 in reply to 31784

Anonymous:
This way you always know what function they came from, and it also helps the compiler optimize your code, making it less likely to confuse them with variables from another function.

Anyone else have any variable naming tips they'd like to share?


I can never tell if you are joking with this stuff.  I'm just going to assume you are.

Re: theInfamousI and The Responsible Guy

2005-03-24 17:41 • by itchi
31791 in reply to 31775
   w      w__
_,\ |_(
\,'\ | |
'./`.__/_`' \ / _
T' `--.____oVo_/o|
,-.-| _____|
/ , \ ,-. `.XXX
\ -'_,'`. vv v\ `-.__`-.
( \ `. vv `. `-'
\ | `-.v `-.
|_3 `-. `.
\ `.
| \
| |
_ / /
. \`,' ,'
\'-._|\_|\,' _,'
`-._________,-'
| |
| |
| |___
|___

BURNITATING THE COUNTRYSIDE!

Re: theInfamousI and The Responsible Guy

2005-03-24 17:53 • by loneprogrammer
31792 in reply to 31784
Anonymous:

Anyone else have any variable naming tips they'd like to share?


I use ROT13 on all my variable names.  For security.



Re: theInfamousI and The Responsible Guy

2005-03-24 18:01 • by dubwai
31793 in reply to 31792

loneprogrammer:

I use ROT13 on all my variable names.  For security.


You can always use the characters from the Simpsons.  The nice thing about that is that it's almost impossible to run out of names.

Re: theInfamousI and The Responsible Guy

2005-03-24 18:13 • by Free
31794 in reply to 31766

RiceCrispies(Snap(Crackle(Pop() ) ) )


Ugh.


With a joke name, you know it wont be called from many places so you can just get rid of it.


If the names are real-world,use Introduce Explaining Variable.


 


 


 

Re: theInfamousI and The Responsible Guy

2005-03-24 18:32 • by e(OR)
I had a function along these lines once... spankthekids() fired from
the controller and rebooted all the child nodes (machine controllers)
when they got unruly and nothing but a systemwide restart would do the
trick (read: When admin decided we should reboot erverything... just to
see if it helps)...

Re: theInfamousI and The Responsible Guy

2005-03-24 18:39 • by Kippesoep
31796 in reply to 31789
Hungarian, actually. Problem is, I don't speak Hungarian.

Re: theInfamousI and The Responsible Guy

2005-03-24 19:12 • by Brian
31799 in reply to 31796
Brings a whole new meaning to the phrase 'hungarian notation'

Re: theInfamousI and The Responsible Guy

2005-03-24 21:10 • by StrongBad
the Trogdor comes in the NIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGHT!

Re: theInfamousI and The Responsible Guy

2005-03-24 23:38 • by Schol-R-LEA
31805 in reply to 31799
I have to confess to committing such silliness back in my first
semi-professional programming job, a POS (in both senses of the term)
for a store I was working for. The sordid details can all be found
here (a slightly
different version can also be seen
here).



Among the groaners were:


  • the employee database was named Slaves, and the indexes for
    current and former employees were named Stuck and Canned, while the
    login list was named Lusers


  • similarly, the Ccustomers database had indexes named Suckers, Marks and Rubes


  • the error handler, Oops, opened a window name S_O_L

  • the flag to indicate whether a customer was in the database was named Cus_P

  • Each file had a comment declaring "This code is cursed"; I had
    read about this comment appearing in some source code somewhere once,
    and I found it humorous enough to use it as a kind of 'good luck charm'
    in my code for a number of years


Fortunately, I have mostly grown out of this sort of thing, though I do
get creative with example code from time to time; for example,  I
once posted a pair of sample assembly language programs (I was
demonstrating how the Netwide Assembler's %include directive worked to a newcomer) named Phant.asm and Org.asm...

Re: theInfamousI and The Responsible Guy

2005-03-25 01:36 • by em
31807 in reply to 31777
BradC:

Anonymous:
What language do YOU use that you can use ++ in your identifier name?  I'm a Microsoft guy and I truly don't know the answer to that because MS languages don't allow it.
I think he just meant that the variable was "theInfamousI". He didn't say it that way, but I also can't imagine any language that would support that as a legal variable name.




Welcome to MzScheme version 208, Copyright (c) 2004 PLT Scheme, Inc.
> (define ++ 5)
> ++
5
> (define + -)
> (+ 5 1)
4

Re: theInfamousI and The Responsible Guy

2005-03-25 01:38 • by em
31808 in reply to 31807
Aaargh, your forum software formatted that correctly in the preview, which is definitely a WTF.

Anyway, the point I was trying to make: Scheme has no reserved identifiers at all, and almost all characters are allowed in identifiers. So, "++" is a valid identifier in Scheme...

Re: theInfamousI and The Responsible Guy

2005-03-25 02:07 • by diGriz
When I get bored while programming, I also tend to use such names for
variables, methods etc. When I was at the university, I had to write a
very boring piece of source. Because I read some very famous comic
books at that time ("Werner"), I only used the comic sounds as names.
It was fully documented, and the program just did what it was supposed
to be, but just reading the source without the comments wouldn't give
you a single hint, what this program was supposed to do.

Re: theInfamousI and The Responsible Guy

2005-03-25 02:38 • by V.


  • CodeToad
  • WhosYourDaddy(node) *This actually is the function to get the parent node
  • Census(node) *This it turned out returned all child nodes
  • disndat(dis, dat) * compares two objects
  • Seperate linked functions called like this RiceCrispies(Snap(Crackle(Pop() ) ) )
  • A very nice acsii image of trogdor
  • Incrementers named things like theInfamousI++


  • If it's not too unclear I find it rather funny to do things a little different. (If you don't exaggerate, that is [:D])  All work and no play makes Jack a dull boy...

    Re: theInfamousI and The Responsible Guy

    2005-03-25 02:41 • by Tom
    31814 in reply to 31792
    loneprogrammer:
    I use ROT13 on all my variable names.  For security.


    I go one step further -- I use Hungarian Notation.

    Re: theInfamousI and The Responsible Guy

    2005-03-25 06:02 • by bxc
    31816 in reply to 31774
    Anonymous:
    What language do YOU use that you can use ++ in your identifier name?  I'm a Microsoft guy and I truly don't know the answer to that because MS languages don't allow it.
    At least Common Lisp and Scheme allow it.

    Re: theInfamousI and The Responsible Guy

    2005-03-25 07:04 • by Bruce (from Down Under)
    31817 in reply to 31777
    {I think he just meant that the variable was
    "theInfamousI". He didn't say it that way, but I also can't imagine any
    language that would support that as a legal variable name.}




    Try FORTH or FACTOR to start with, I'm not sure but I
    think even Smalltalk, and some of the functional languages will allow
    this.



    This entire discussion has brought tears to my eyes - it has been so
    funny. Over the last tweny odd years, the industry has come up with
    some doozies.



    Enjoy your weekend Ladies and Gentlemen.


    Re: theInfamousI and The Responsible Guy

    2005-03-25 08:12 • by JamesCurran
    31820 in reply to 31779
    JamesCurran:
    To document it, a wrote a short story -- a spoof of Sherlock Holmes --- which explained how it worked.  There was a "Mysterious Mr. X" and a dog named "Ptr".  (If I recall correctly, it was called "The Strange Case of Polly Nomial")

    I probably still have the listing somewhere......


    OK, I found the list.  However, 20 year old computer listings (on greenbar paper) don't OCR very well, so post it, I've had to scan it as images and post the GIFs.


    If you want to read it, it's at:


    http://honestillusion.com/photos/the_strange_case_of_polly_nomial


     


     

    Re: theInfamousI and The Responsible Guy

    2005-03-25 09:27 • by IowaCBR600F4Guy.....can't get my new password at the moment
    31823 in reply to 31820
    That is an awesome story james

    Re: theInfamousI and The Responsible Guy

    2005-03-25 10:10 • by Pragma
    31825 in reply to 31820
    JamesCurran:
    OK, I found the list.  However, 20 year
    old computer listings (on greenbar paper) don't OCR very well, so post
    it, I've had to scan it as images and post the GIFs.

    If you want to read it, it's at:


    http://honestillusion.com/photos/the_strange_case_of_polly_nomial




    Not only was that a good read, but it had to be the most creative
    use of variable names *and* comment space I've ever seen.  The
    intersection of Sherlock Holmes (er.. "Houses"), aptly-named biblical
    references, lyrics/poetry, and a double-helix indentation scheme.


    ...although if that was in production (commercial) code, I'd smack you with a trout. 


    10/10 WTF points. (would've been a '9' but the code obviously predates Trogdor)


    Re: theInfamousI and The Responsible Guy

    2005-03-25 10:12 • by Fromeo
    31826 in reply to 31823
    The variable names remind me of a program I wrote at one point that
    involved a leftist heap
    (http://www.cs.dartmouth.edu/~chepner/cs15/notes/16_heaps.html). 
    I called the whole structure a commie_heap, and named all the local
    variables within the implementation after communist leaders, so you'd
    have functions like:



    commie_heap_merge(struct commie_heap *lenin, struct commie_heap *trotsky)



    ...and so on.

    Re: theInfamousI and The Responsible Guy

    2005-03-25 10:36 • by Blake Miller
    31828 in reply to 31784

    C and C++ would NEVER confuse a local variable with 'another variable from another function'.  It just can't happen.


    If I want to name a local variable the same as something already global, I usually put an l_ in front of the name.  There is no need to put the entire function name in front of a variable like you do if writing in C and C++, and it really contributes nothing to the clarity of the code whatsoever.


    Unless your I or X are used trivially, you would do better to spend your time naming them something other than 'I' and 'X'.


     

    « PrevPage 1 | Page 2Next »

    Add Comment