• Me (unregistered)

    So, what's so bad about the grammatical error?

  • Sole Purpose Of Visit (unregistered)

    I once dealt with a piece of code that implemented a persistent internal database in C++, with pointers and all. It had the following comment:

    // DO NOT TOUCH THIS CODE! It is very complicated.  If you touch it, you will break it!
    

    I didn't even need to touch it to break it -- just changing from a 32-bit architecture to a 64-bit architecture did that all on its own.

    Needless to say, when I fixed the code, I removed the comment.

  • (nodebb)

    This made me think of a comment I once saw in production code, saying that the code immediately below didn't work and nobody knew why.

    I stared at the body of code for about ten minutes, following the chain of events, and found out why. This revelation was not well received by the people who had produced the code in question.

  • some guy (unregistered)

    mandatory reference:

    https://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered

  • my name is missing (unregistered)

    This comment has leaked into production.

  • (nodebb)

    I miss when Remy used to hide interesting comments in the article source. At least my Cornify bookmarklet still works.

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    Just the good old:

    // DO NOT COMMIT
    

    and

    // DO NOT PUSH
    

    which, inevitably, get committed and pushed.

  • 🤷 (unregistered)

    Comments can sometimes lie. Code never does.

  • LCrawford (unregistered) in reply to 🤷

    | Comments can sometimes lie. Code never does.

    int one=5; int ten=6; int eleven = one + ten; // true

  • ooOOooGa (unregistered) in reply to LCrawford

    Shallow copy of object created by a pass-by-value function argument.

  • (nodebb)

    ... the lines that followed are completely harmless in production…

    There's your WTF ^^^

  • (nodebb) in reply to Bananafish

    I bet they are ..... Mostly Harmless

  • (nodebb)

    Sounds like someone already took out the dangerous code and left the comment. Or, to quote the Rocky Horror Picture Show, they removed the cause...but NOT the symptom.

  • JustaDBA (unregistered) in reply to Steve_The_Cynic

    Yeah, people tend to hate it when you fix their mistakes. Corporatism 101.

  • Dave Aronson (google)

    the lines that followed are completely harmless in production…

    Those were probably not the lines that originally followed. As usual, the code was changed but the comments were untouched.

  • David Katz (google)

    my favorite comment ever is "this doesn't really do anything anymore". So you took the effort to write the comment, but not to remove the unnecessary code? Great work!

  • James (unregistered) in reply to David Katz

    Those comments exist where the process to make a small change is too unwieldy.

  • Airdrik (unregistered) in reply to James

    Or there's insufficient tests/testing to ensure that removal of the "useless code" in fact breaks nothing in that one business-critical component that nobody really understands anymore.

  • torgefaehrlich (unregistered) in reply to Dave Aronson

    And then people ask me why I’m against the policy of always putting comments on a separate line.

  • xtal256 (unregistered)

    I remember a few years ago seeing a comment that went something like: "This code is obsolete. If still here by March 1998, please remove it"

    I'm pretty sure the code was commented-out, but it and the comment remained for almost 20 years before I found and removed it.

  • 🤷 (unregistered) in reply to LCrawford

    Q.E.D.!

  • David Mårtensson (unregistered) in reply to my name is missing

    Well, the comment only says to not let the code pass into production, it does not say anything about the comment ...

    ;)

  • (nodebb) in reply to Sole Purpose Of Visit

    Years ago, I ran into a function whose assumed inputs (top N elements of the stack) were documented solely as "you don't want to know", and had to wade through the code to reconstruct what they were (N turned out to be 8 in that instance).

  • Ville (unregistered)

    Complete source code:

    // WARNING!!! Special case for [external API] testing. // DO NOT LET THIS PIECE OF CODE FIND IT'S WAY TO PRODUCTION #if development DoSomethingNastyWithApi(); #end if

  • Some Ed (unregistered)

    I feel like comments are an important tool to explain why you're doing something. Except for regular expression comments, they shouldn't also say what, because what should be pretty clearly conveyed by the code itself. Regular expressions can be pretty obuse, though, so if the regex is complicated, it's excusable to explain what and how the regex is doing this task.

    Some of my coworkers tend to feel like comments are a good way to retain code that's stored in version control so that we can look back and see what had previously been done here. I mean, back when the code was being developed, because they stop making comments after they feel like they're ready for deployment. And, by 'here', I mean in the company they work for, because they have this distinct tendency to move comments, both theirs and mine, more or less whenever they copypasta.

    It's probably also noteworthy that happens before they make any edits to the code, including deciding the whole copypasta was a bad idea, and delete all of the code they copied, but leave the comments behind.

    At least it usually feels pretty safe to reject proposed changes that simply add a random selection of comments from wherever to code that needs correction, and then call it good.

Leave a comment on “Production Comments”

Log In or post as a guest

Replying to comment #:

« Return to Article