The Worst Comments

  • when someone leaves behind a //TODO: with just their name. No info about what it was that they left to do.

    Then you find this comment 6 months later, and either that person no longer works with you, or they have no idea what it was that they needed to do...

  • Absolutely the worst comment I have ever seen in code, and it was all over the place at one previous shop I worked at:

    -- Process data

    It wasn't in SQL though. That was just for illustration. 🙂


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • The worst I have seen is

    --Works as Coded

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Seen everything between a shopping list to poetry, not bothered too much by those, at least not as much as having several hundreds of routines which all had a very nice, well formatted header comment with nothing but the developer's names in them.

    😎

  • MLK44 (3/12/2015)


    .

    +1. What's worse: bad comments or no comments?


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Comments posted to this topic are about the item The Worst Comments

  • Many years ago I found a comment by my boss in the code which read something along the lines of

    -- Don't touch this code

    -- It does fancy statistical maths on an iterative loop until it gets the answer

    -- Really, don't touch it

    -- Even if you think you kn ow what you are doing, DON'T

    It served one useful purpose. It warned me that the next page was complex. It didn't tell me anything about what it was actually doing!

  • Another +1 for 'no comments' . I'm working on updating a bunch of non-SQL test scripts at the moment, which feature many examples of complex, multi-call tests with not a shred of explanation between them. Makes for a speedy update!

  • Toby Harman (3/13/2015)


    Many years ago I found a comment by my boss in the code which read something along the lines of

    -- Don't touch this code

    -- It does fancy statistical maths on an iterative loop until it gets the answer

    -- Really, don't touch it

    -- Even if you think you kn ow what you are doing, DON'T

    It served one useful purpose. It warned me that the next page was complex. It didn't tell me anything about what it was actually doing!

    Sometimes quotes say a lot more about the author than the reader.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • I was going to try and say "no comment" in a witty way but as I am not first to highlight the issue (and I am not always that witty) I shan't bother. Instead I have the following anecdote:

    I have recently worked with people who have analysed code because of the lack of documentation (i.e. no specification and limited/poor/non-existent comments) and made paper notes then augmented the code with their own uncommented code. Muppets.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • No comments aside, my least favourite style of commenting is one that breaks encapsulation. I have seen comments that describe how a call is implemented at the point of making that call as opposed to what it is supposed to achieve. This is unnecessary information for the reader as they will not care unless they drill down to that level. On top of that, if the implementation changes then the comments that are nowhere near the changed code becomes out of date and, in my opinion, dangerously wrong. Down this road lies misconceptions, information overload and confusion.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Superfluous comments are worse than no comments. You know the type:

    --Find the average

    select @avg = avg(x)

    Reminds me of those people who, when doing presentations, just recite what is written on screen.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • --do something

    --do something else

    --not sure what this does

    --changed

  • Guilty as charged!

    ---show output

    select * from #output_2

    This is one of my comment. I knew I'd done something somewhere. And to be honest I do this all the time. However may I lay at my extenuating circumstances at the door of the judges. If we take the whole of the comments in the stored procedure and remove the code, together it does all make logical sense like a book. And that's sort of instead of putting

    --The End

    Which thinking about it I'll start using.

    However as a stand alone it looks a bit retarded.

  • I have two 'favourites'

    -- Abandon hope all ye who enter here

    And, from my days of assembler programmimng

    ldx 1 -- Load the x register with 1

    ldx 1 -- Just in case it didn't do it the first time

Viewing 15 posts - 1 through 15 (of 156 total)

You must be logged in to reply to this topic. Login to reply