Funniest/Most Annoying Code Comments

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

simo
Posts: 227
Joined: Sat Dec 08, 2007 12:17 am UTC
Location: In ma Bucket! (bournemouth uk)
Contact:

Re: Funniest/Most Annoying Code Comments

Postby simo » Mon Mar 31, 2008 3:22 pm UTC

I cant wait till my programming tutor marks the game engine I'm coding. MWHAHA!

Code: Select all

void Log( const char *fmt)
{

   FILE *log;
   log = fopen ("log.txt", "a");
   fprintf (log, fmt);
   fclose (log);

}

/*   "What rolls down stairs alone or in pairs
    Rolls over your neighbor's dog?
    What's great for a snack and fits on your back?
    It's Log, Log, Log!
 
    It's Log, Log, it's big, it's heavy, it's wood.
    It's Log, Log, it's better than bad, it's good!
    Everyone wants a log! You're gonna love it, Log!
    Come on and get your log! Everyone needs a Log!"
*/

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Berengal » Mon Mar 31, 2008 4:34 pm UTC

What sound does drowning mathematicians make? Log log log...
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

coppro
Posts: 117
Joined: Mon Feb 04, 2008 6:04 am UTC

Re: Funniest/Most Annoying Code Comments

Postby coppro » Mon Mar 31, 2008 10:48 pm UTC

simo wrote:I cant wait till my programming tutor marks the game engine I'm coding. MWHAHA!

Code: Select all

void Log( const char *fmt)
{

   FILE *log;
   log = fopen ("log.txt", "a");
   fprintf (log, fmt);
   fclose (log);

}
You know, it's probably really slow to open the file every time you need to write with it... you should probably just open it once and then close it when you are done with the program.

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby mrkite » Mon Mar 31, 2008 10:52 pm UTC

coppro wrote:You know, it's probably really slow to open the file every time you need to write with it... you should probably just open it once and then close it when you are done with the program.


Maybe he wants to be able to tail the file while the program is running. Plus, the log should only be used for debugging anyway. Having a production program constantly appending to a file == bad.

simo
Posts: 227
Joined: Sat Dec 08, 2007 12:17 am UTC
Location: In ma Bucket! (bournemouth uk)
Contact:

Re: Funniest/Most Annoying Code Comments

Postby simo » Mon Mar 31, 2008 11:06 pm UTC

mrkite wrote:
coppro wrote:You know, it's probably really slow to open the file every time you need to write with it... you should probably just open it once and then close it when you are done with the program.


Maybe he wants to be able to tail the file while the program is running. Plus, the log should only be used for debugging anyway. Having a production program constantly appending to a file == bad.


indeed. The log is only to catch my segfaults at the moment, and to pick up on any unclean exits.

(and to roll over my neighbours dog)

User avatar
Mr. Heavy
Posts: 25
Joined: Tue Mar 25, 2008 11:53 pm UTC
Location: Long Island, NY
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Mr. Heavy » Mon Mar 31, 2008 11:12 pm UTC

mrkite wrote:Maybe he wants to be able to tail the file while the program is running.

tail -f works basically by running feof() in a loop until it fails, then reading to the end of file, so I don't see what that would possibly accomplish.

(If you want to be pedantic, feof() works on streams and tail uses file descriptors. I haven't read the source.)

mrkite wrote:Plus, the log should only be used for debugging anyway. Having a production program constantly appending to a file == bad.

It really isn't a problem provided you have competent administrators who know how to rotate logs (and your application knows how to open the new file descriptor after it's rotated without completely restarting). logadm/logrotate/whatever have been around for years and years.

Unless you're running a database application, or staging files to a large HPC cluster simultaneously, you're probably not bound by disk I/O enough to be affected by logging.

mrkite
Posts: 336
Joined: Tue Sep 04, 2007 8:48 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby mrkite » Mon Mar 31, 2008 11:51 pm UTC

Mr. Heavy wrote:tail -f works basically by running feof() in a loop until it fails, then reading to the end of file, so I don't see what that would possibly accomplish.


Unless he explicitly flushes the stream (which will have the same performance hit as fclose) tail won't print anything until the stream fills up. If he segfaults, that file will be empty.

User avatar
Babam
the Nearly Deleted
Posts: 1170
Joined: Tue Apr 01, 2008 2:05 am UTC
Location: A multiverse, wandering the couch
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Babam » Tue Apr 01, 2008 6:45 am UTC

RIPJSB
next to the number 1750 in Peter Sampsons music hack for the TX-0
Let me know when you figure it out ;)
Spoiler:
crucialityfactor wrote:I KNEW he could club bitches!

SecondTalon wrote:Reality - More fucked up than Photoshop.

s/notwittysig/wittysig

User avatar
scowdich
The Hedgehog
Posts: 771
Joined: Tue May 22, 2007 4:55 am UTC
Location: University of Illinois (Urbana-Champaign)
Contact:

Re: Funniest/Most Annoying Code Comments

Postby scowdich » Tue Apr 01, 2008 7:23 am UTC

"Rest in peace, Johann Sebastian Bach". Easy. 1750 was the year of his death; where better to commemorate it than the code for an electric organ?
Also, the Tixo rocks all socks which are currently available.

User avatar
Babam
the Nearly Deleted
Posts: 1170
Joined: Tue Apr 01, 2008 2:05 am UTC
Location: A multiverse, wandering the couch
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Babam » Tue Apr 01, 2008 10:59 pm UTC

scowdich wrote:"Rest in peace, Johann Sebastian Bach". Easy. 1750 was the year of his death; where better to commemorate it than the code for an electric organ?
Also, the Tixo rocks all socks which are currently available.

Did you happen to read Steven Levy's book, Hackers Heros of the Computer Revoloution?
Spoiler:
crucialityfactor wrote:I KNEW he could club bitches!

SecondTalon wrote:Reality - More fucked up than Photoshop.

s/notwittysig/wittysig

User avatar
scowdich
The Hedgehog
Posts: 771
Joined: Tue May 22, 2007 4:55 am UTC
Location: University of Illinois (Urbana-Champaign)
Contact:

Re: Funniest/Most Annoying Code Comments

Postby scowdich » Tue Apr 01, 2008 11:52 pm UTC

...maybe.

User avatar
Babam
the Nearly Deleted
Posts: 1170
Joined: Tue Apr 01, 2008 2:05 am UTC
Location: A multiverse, wandering the couch
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Babam » Wed Apr 02, 2008 12:06 am UTC

scowdich wrote:...maybe.

So in less words yes?
Spoiler:
crucialityfactor wrote:I KNEW he could club bitches!

SecondTalon wrote:Reality - More fucked up than Photoshop.

s/notwittysig/wittysig

User avatar
Mr. Heavy
Posts: 25
Joined: Tue Mar 25, 2008 11:53 pm UTC
Location: Long Island, NY
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Mr. Heavy » Wed Apr 02, 2008 12:59 pm UTC

mrkite wrote:Unless he explicitly flushes the stream (which will have the same performance hit as fclose) tail won't print anything until the stream fills up. If he segfaults, that file will be empty.

Hitting fflush() after every write or not flushing it ever isn't an either/or proposition, though. You can very much flush the stream frequently and intelligently.

And unless you're dumping stack traces of every function call you make, or are processing 800 transactions/second on a development machine for some reason (to test a race condition, maybe) I really don't see how the performance overhead of fflush() as it relates to logging is possibly relevant in the year 2008.

User avatar
Hammer
Because all of you look like nails.
Posts: 5491
Joined: Thu May 03, 2007 7:32 pm UTC
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Hammer » Wed Apr 02, 2008 1:12 pm UTC

Those of you having the off-topic log file argument can stop now.
"What's wrong with you mathematicians? Cake is never a problem."

User avatar
biolution
Ken
Posts: 560
Joined: Wed Sep 05, 2007 10:05 pm UTC
Location: San Francisco, Ca
Contact:

Re: Funniest/Most Annoying Code Comments

Postby biolution » Wed Apr 02, 2008 4:41 pm UTC

This is somewhere around line 2000, which is only halfway through the file.

Code: Select all

// setting the proper ticket type..
/* @note $className isn't a class name, its the ticket type
 * but we're avoiding potential conflicts with $type and $ticketType
 * since we don't know if they're being used later (sometimes they are
 * and sometimes they aren't)
 */
$className = $ddm->getTypeByCreatePageName($createPageName);

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Berengal » Fri Apr 04, 2008 12:13 pm UTC

Code: Select all

      // <ugly reason="java IO">
      ObjectInputStream in = null;
      try {
         // [#include more_uglyness]
      } finally {
         try {
               in.close();
            } catch (IOException e) { // When will it ever end? Geez...
               e.printStackTrace();
               System.exit(1);
            }
      }
      // </ugly>

The original coder was apparantly wtf-ing as much as I am when he wrote this.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
RedWolf
Posts: 236
Joined: Mon Dec 31, 2007 8:19 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby RedWolf » Fri Apr 04, 2008 6:48 pm UTC

I'm glad to see somebody else codes by putting the opening brace at the end of the first line instead of at the beginning of the line below it :D

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Xanthir » Fri Apr 04, 2008 7:18 pm UTC

Fwiw, I do that too. It's a common coding style. I originally learned to put all braces on their own line, but completely grew out of it when I learned Lisp (there, the parens follow the code down onto the next line). It so happened that the first major non-Lisp project I did was in Javascript, where this coding style seems to be the norm. That trained me completely.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Berengal » Fri Apr 04, 2008 7:54 pm UTC

It's the Java standard, and it's how eclipse formats for me. Personally I barely notice any difference between different brace styles anyway, as long as the indentation follows python rules (which most code does).
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

jtniehof
Posts: 312
Joined: Mon Sep 10, 2007 9:00 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby jtniehof » Fri Apr 04, 2008 9:13 pm UTC

RedWolf wrote:I'm glad to see somebody else codes by putting the opening brace at the end of the first line

It's K&R, ergo, the One True Way. Although I tend to abuse it for functions as well.
(tongue in cheek; this need not go to religious wars....really....)

User avatar
Hammer
Because all of you look like nails.
Posts: 5491
Joined: Thu May 03, 2007 7:32 pm UTC
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Hammer » Fri Apr 04, 2008 9:42 pm UTC

jtniehof wrote:It's K&R, ergo, the One True Way. Although I tend to abuse it for functions as well.
(tongue in cheek; this need not go to religious wars....really....)

But, if it did, there's a thread for it.
"What's wrong with you mathematicians? Cake is never a problem."

User avatar
RedWolf
Posts: 236
Joined: Mon Dec 31, 2007 8:19 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby RedWolf » Sat Apr 05, 2008 2:37 am UTC

Well it seems its more popular than I thought. My teacher teaches the other way, and my friend and I are the only people in the school who code this way.

User avatar
ACF
Posts: 23
Joined: Sun Nov 04, 2007 2:41 am UTC

Re: Funniest/Most Annoying Code Comments

Postby ACF » Mon Apr 07, 2008 5:58 am UTC

From John Romero's (of Id Software) TED5 level editor:

Code: Select all

////////////////////////////////////////////////////
//
// Start of The Beast From Hell
//
////////////////////////////////////////////////////

User avatar
segmentation fault
Posts: 1770
Joined: Wed Dec 05, 2007 4:10 pm UTC
Location: Nu Jersey
Contact:

Re: Funniest/Most Annoying Code Comments

Postby segmentation fault » Mon Apr 07, 2008 7:54 pm UTC

Code: Select all

      /* Number pulled out of my ass */
      if (request->udp && ((x % 800920) == 0))
people are like LDL cholesterol for the internet

rator10
Posts: 10
Joined: Fri Apr 11, 2008 4:14 am UTC

Re: Funniest/Most Annoying Code Comments

Postby rator10 » Fri Apr 11, 2008 5:26 am UTC

Please don't kill me, but....
In an operating systems assignment because I didn't feel like doing the work to not write it this way:

Code: Select all

  //yes, the ; is necessary... no, I don't know why... but remove it! it won't compile!
 startCPU:;


and later in the code:

Code: Select all

                  /* The following goto is to protect the stack
                   * from a possible over-flow. The original line
                   * of code at this location was Cpu(). However,
                   * if there were repeated SKIP 0 JUMP [x,y]
                   * commands, the stack would have overflowed.
                   * to protect against that, this goto was added.
                   * A gigantic while loop could have been used,
                   * but this was faster */
                  //Cpu(callDeep + 1);
                  goto startCPU;


specifically the: "a gigantic while loop could have been used, but this was faster"

Oh, and a raptor didn't attack me... http://xkcd.com/292/ he must still be on his way *shifty glance around self*

User avatar
r1chard
Posts: 281
Joined: Thu Dec 06, 2007 2:17 am UTC
Location: Melbourne, AU
Contact:

Re: Funniest/Most Annoying Code Comments

Postby r1chard » Fri Apr 11, 2008 5:34 am UTC

Our in-house SMS packet (TPDU - a truly fun wire protocol which packs data in as tightly as it'll go) codec:

Code: Select all

            # Oh. My. God. 7 bit coded alphanumeric address. Kill me.
            # No, wait. Kill everyone involved in the creation of this spec.
            inst.address = unpack7bit(hexdecode(address), 0)

and then a little later in the unpack7bit function:

Code: Select all

    if hl == 0:
        curOff = 0
    else:
        # I quote from section 9.2.3.24 of GSM 03.40:
        # If 7 bit data is used and the TP-UD-Header does not finish on
        # a septet boundary then fill bits are inserted after the last
        # Information Element Data octet up to the next septet boundary
        # so that there is an integral number of septets for the entire
        # TP-UD header. This is to ensure that the SM itself starts on
        # an septet boundary so that an earlier Phase mobile will be
        # capable of displaying the SM itself although the TP-UD Header
        # in the TP-UD field may not be understood. Please kill me now.
        curOff = (7-((8*hl+1)%7))%7
        ...

Yes, you read that right. Septets. "Please kill me now" indeed. And finally:

Code: Select all

def nibbleswap(bytes):
    # How much do I fucking hate SMS TPDU format?
    # nibbleswapping the output is the final indignation
    bytes = [ord(x) for x in bytes]
    bytes = [(b&0xF0)>>4 | (b&0x0F)<<4 for b in bytes]
    bytes = ''.join([chr(x) for x in bytes])
    return bytes

User avatar
phlip
Restorer of Worlds
Posts: 7569
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Funniest/Most Annoying Code Comments

Postby phlip » Fri Apr 11, 2008 5:43 am UTC

rator10 wrote:

Code: Select all

  //yes, the ; is necessary... no, I don't know why... but remove it! it won't compile!
 startCPU:;

Let me guess, the very next thing was a variable declaration?

Labels (and cases in a switch statement, which are just glorified labels anyway) have to be followed by an actual statement... a variable declaration doesn't count. A null statement, however, does count.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
biolution
Ken
Posts: 560
Joined: Wed Sep 05, 2007 10:05 pm UTC
Location: San Francisco, Ca
Contact:

Re: Funniest/Most Annoying Code Comments

Postby biolution » Fri Apr 11, 2008 5:49 am UTC

r1chard wrote:nibbleswap


At first I read "nippleswap." I think my new goal is to enter this term into popculture. "Oh hey, can you nibbleswap this really quick?"

Posi
Posts: 111
Joined: Mon Jul 16, 2007 6:08 am UTC

Re: Funniest/Most Annoying Code Comments

Postby Posi » Fri Apr 11, 2008 6:17 am UTC

Berengal wrote:

Code: Select all

      // <ugly reason="java IO">
      ObjectInputStream in = null;
      try {
         // [#include more_uglyness]
      } finally {
         try {
               in.close();
            } catch (IOException e) { // When will it ever end? Geez...
               e.printStackTrace();
               System.exit(1);
            }
      }
      // </ugly>

The original coder was apparantly wtf-ing as much as I am when he wrote this.

I like this one. I also love the fact that in the Java tutorials, they completely gloss over the fact that close() does throw a checked exception. That made trying to learn file io so easy to learn. At the time I wasn't sure what was going on, but when I copypastaed on of their code examples and it did not compile I nearly cried.

I think they ought to do something about that.

User avatar
biolution
Ken
Posts: 560
Joined: Wed Sep 05, 2007 10:05 pm UTC
Location: San Francisco, Ca
Contact:

Re: Funniest/Most Annoying Code Comments

Postby biolution » Fri Apr 11, 2008 6:45 am UTC

Posi wrote:I like this one. I also love the fact that in the Java tutorials, they completely gloss over the fact that close() does throw a checked exception. That made trying to learn file io so easy to learn. At the time I wasn't sure what was going on, but when I copypastaed on of their code examples and it did not compile I nearly cried.

I think they ought to do something about that.


You know, I've always wondered what the right course of action is when you can't close a file or other resource. It seems like such a...non-real problem.

Usually its
open()
value = read, write, compute, etc
close()
return value

After which, well...everything is done. I mean, if you can't close it, what are you suppose to do, read from it some more? I can understand the need for correctness, I just can't see the actual *use* of it.

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: Funniest/Most Annoying Code Comments

Postby Sc4Freak » Fri Apr 11, 2008 7:12 am UTC

biolution wrote:
Posi wrote:I like this one. I also love the fact that in the Java tutorials, they completely gloss over the fact that close() does throw a checked exception. That made trying to learn file io so easy to learn. At the time I wasn't sure what was going on, but when I copypastaed on of their code examples and it did not compile I nearly cried.

I think they ought to do something about that.


You know, I've always wondered what the right course of action is when you can't close a file or other resource. It seems like such a...non-real problem.

Usually its
open()
value = read, write, compute, etc
close()
return value

After which, well...everything is done. I mean, if you can't close it, what are you suppose to do, read from it some more? I can understand the need for correctness, I just can't see the actual *use* of it.

In C++, it's an incredibly bad idea to throw an exception from a destructor, which is where you'd do things like closing file handles (if you're utilising good RAII techniques). If the destructor was a part of a stack unwind due to a previous exception being thrown, then C++ calls terminate(), which kills your application. This is because, during a stack unwind, C++ can't decide what to do if another exception is thrown while it's in the process of throwing a previous exception.

In the Win32 API, performing cleanup operations such as closing file handles can never fail. They always succeed, but sometimes with errors. In that case, there's nothing you can do to "cleanup from a failed cleanup".

User avatar
jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

Re: Funniest/Most Annoying Code Comments

Postby jaap » Fri Apr 11, 2008 10:28 am UTC

biolution wrote:
Posi wrote:I like this one. I also love the fact that in the Java tutorials, they completely gloss over the fact that close() does throw a checked exception.
[snip]
I think they ought to do something about that.


You know, I've always wondered what the right course of action is when you can't close a file or other resource. It seems like such a...non-real problem.


Most file access is buffered. If you write to a file, it might be kept in a buffer and not actually be written until the file gets closed.
Closing a file may fail if the drive is no longer accessible, for example if it is a network drive, or usb stick. In such a case data may get lost.

If you close a program and it finds an error when trying to close the data file it saves your work to, you might prefer it to give you the option of choosing a different file to save everything to, rather than just give up and quit.

In Java they've chosen to flag all such bad things with exceptions rather than some return value. It could just as easily have been done via return values, but that is the design choice they made.

User avatar
phlip
Restorer of Worlds
Posts: 7569
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Funniest/Most Annoying Code Comments

Postby phlip » Fri Apr 11, 2008 11:22 am UTC

I can't speak for Java (the Java docs don't specify what circumstances might make FileWhatever.close() throw an exception, or which IOException subclass it could throw), but in POSIX C:

fclose(3) wrote:ERRORS

The fclose() function shall fail if:

EAGAIN
The O_NONBLOCK flag is set for the file descriptor underlying stream and the process would be delayed in the write operation.

EBADF
The file descriptor underlying stream is not valid.

EFBIG
An attempt was made to write a file that exceeds the maximum file size.

EFBIG
An attempt was made to write a file that exceeds the process’ file size limit.

EFBIG
The file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding stream.

EINTR
The fclose() function was interrupted by a signal.

EIO
The process is a member of a background process group attempting to write to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU, and the process group of the process is orphaned. This error may also be returned under implementation-defined conditions.

ENOSPC
There was no free space remaining on the device containing the file.

EPIPE
An attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal shall also be sent to the thread.

The fclose() function may fail if:

ENXIO
A request was made of a nonexistent device, or the request was outside the capabilities of the device.

Most of those errors would, as jaap explained, be caused by the flushing of any write-buffered data to the file, rather than the closing itself. I think the only exception is EBADF, which'll get set if you try to fclose() something that isn't a file pointer, and maybe EINTR if you get really unlucky (fclose() should be pretty quick if there's nothing to flush).

The lower-level close() has much fewer errors... just EBADF and EINTR, but it also has the general-purpose EIO which seems to be just all the other errors rolled up into one uninformative error code.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Berengal » Fri Apr 11, 2008 12:05 pm UTC

Why couldn't java just have something nice like python's with (or C#s using, I think. Haven't used it)?
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Hammer
Because all of you look like nails.
Posts: 5491
Joined: Thu May 03, 2007 7:32 pm UTC
Contact:

Re: Funniest/Most Annoying Code Comments

Postby Hammer » Fri Apr 11, 2008 12:56 pm UTC

This is going to get back to comments soon right? Because there's plenty of other threads where you can talk about how Java et al do things...
"What's wrong with you mathematicians? Cake is never a problem."

User avatar
jaap
Posts: 2094
Joined: Fri Jul 06, 2007 7:06 am UTC
Contact:

Re: Funniest/Most Annoying Code Comments

Postby jaap » Fri Apr 11, 2008 1:54 pm UTC

Hammer wrote:This is going to get back to comments soon right?


Fair enough. I just now did some searching through the millions of lines of software of the product I work on, and didn't find as much as I hoped. Here are a few confusing ones (though they probably make sense in context):

/* What do you mean by "quadratic loop" ? */

/* Get the direction indirection */

/* Does this direction have an internal direction ? */

/* Could we be flipping the local(ish) head? */

#ifdef JOHNNY /* who says appending ???, who restores ??? */



A few others in parts of the code I'd rather not have to work in:

/* Implementation was never completed, hence is not accessible from user interface */

// Now comes a bit of a dirty trick to which we are forced because both X and Y have
// some non-virtual methods which we would like to overwrite, but can't.

/* use trick to pretend as if we have arrays that start at element 1 */
arrPtr--;

/* This is an ugly patch to repair the file backcompatibility
* which was messed up after the increase of the maximum number
* of items a viewset can have.
* From now on we only SAVE and LOAD the exact number of items
* which was already available in the file.
*/

// TODO fix this nasty hack.

/* Of course we know far better than [gui-library] how the items should be lay-out... */


I've made minor edits to protect the guilty.

rator10
Posts: 10
Joined: Fri Apr 11, 2008 4:14 am UTC

Re: Funniest/Most Annoying Code Comments

Postby rator10 » Fri Apr 11, 2008 5:34 pm UTC

From a project for a class I'm in:


/*
May be major bugs in this code!
*/

and later in the code:

//maybe?

simo
Posts: 227
Joined: Sat Dec 08, 2007 12:17 am UTC
Location: In ma Bucket! (bournemouth uk)
Contact:

Re: Funniest/Most Annoying Code Comments

Postby simo » Fri Apr 11, 2008 6:11 pm UTC

rator10 wrote:From a project for a class I'm in:


/*
May be major bugs in this code!
*/

and later in the code:

//maybe?


hahaha.

One I just found in my game engine. For bounding box generation.

/* I'm going to make the assumption that the first frame is a good one to build the bb from */

>big chunk of code>


/* What the fuck was I thinking? This is a terrible idea! */

zahlman
Posts: 638
Joined: Wed Jan 30, 2008 5:15 pm UTC

Re: Funniest/Most Annoying Code Comments

Postby zahlman » Fri Apr 11, 2008 8:57 pm UTC

rator10 wrote:Please don't kill me, but....
In an operating systems assignment because I didn't feel like doing the work to not write it this way:


Care to show more of the code? I have a sneaking suspicion that it's much easier to do it the "right" way than you think.
Belial wrote:I once had a series of undocumented and nonstandardized subjective experiences that indicated that anecdotal data is biased and unreliable.

lingomaniac88
Posts: 127
Joined: Wed Apr 09, 2008 2:52 am UTC

Re: Funniest/Most Annoying Code Comments

Postby lingomaniac88 » Sat Apr 12, 2008 12:31 am UTC

Not a comment, but still funny. Borat FTW.

Code: Select all

{
  IllegalArgumentException theJewDownTheWell = new IllegalArgumentException("Positive integer required");
  throw theJewDownTheWell;
}
"It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something."
-- Franklin D. Roosevelt


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 15 guests