The Worst Comments

  • This was removed by the editor as SPAM

  • In the Crystal Reports report interface, there used to be a small space at the bottom where you could expose the underlying HTML code. A comment at the bottom of the page said something to the effect of, “Internet Explorer needs to have this empty DIV tag here. I don’t know why, though.”<!--more-->

  • Query said:

    ...WHERE 1=0...

    Comment in front of the query said:

    -- WHERE 1 = 0

    No explanation for it at all.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • Grant Fritchey wrote:

    Query said: ...WHERE 1=0... Comment in front of the query said: -- WHERE 1 = 0 No explanation for it at all.

    I hate "where 1=0" - I ..use  "where @debugmode=1" and pass that in as a parameter.

    the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying

     

     

    MVDBA

  • Another example of bad commenting in code are when the comments contain actual blocks of commented code with no explanation. Like, if someone tweaks a 100 line SELECT statement, there is really no reason to keep the original statement sitting between /* */ for the sake of posterity. All that's needed is a simple one line comment with the date, developer's name, and a brief explanation that the statement was modified for performance reasons. If the source is maintained in VCS, then it's easy to go back there and see revisions made to the code.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Reviewing legacy code few years back, I came across a view which was couple of hundred Kb in size (object definition's data size). Thinking that that one was something worth looking into, I scripted it and found few thousand lines of comments and code, all commented out and the last line was :

    SELECT * FROM TABLE_NAME

    😎

    The more funny thing was that the name of the view was product related, the table was "person" type table, one couldn't make it up!

     

  • phegedusich wrote:

    In the Crystal Reports report interface, there used to be a small space at the bottom where you could expose the underlying HTML code. A comment at the bottom of the page said something to the effect of, “Internet Explorer needs to have this empty DIV tag here. I don’t know why, though.”<!--more-->

    Haha I have been guilty of comments like that, especially when dealing with bizarre formatting nonsense with IE. There are times with IE that you just have to muck around until find something that is acceptable to its non-standard interpretation of HTML.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Years ago I came across comments in the code that contained the logon credentials for the DB server. Sysadmin account too - of course. It was for a DEV system so nobody cared. I just shake my head when I see stuff like that.

  • My two favourites were both from COBOL programs many years ago.

    1. At the very top of the program, "This program operates on a finite state machine concept". That was the only comment in the program.
    2. Buried somewhere below reams of GO TO,  PERFORM and IF...ELSE logic, I found "I'm pretty sure you can't get here, but I'm leaving it in just in case".
  • MVDBA (Mike Vessey) wrote:

    I hate "where 1=0" - I ..use  "where @debugmode=1" and pass that in as a parameter. the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying    

    WHERE 1 = 0 is not always a debugging construct.

    Eg.

    SELECT ... INTO #SomeTable WHERE 1 = 0

    Creates an empty temp table with the desired structure (as defined in the SELECT).

    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.

  • Phil Parkin wrote:

    MVDBA (Mike Vessey) wrote:

    I hate "where 1=0" - I ..use  "where @debugmode=1" and pass that in as a parameter. the number of times one of my devs has hardcoded "where 1=2" and forgotten to take it out is annoying    

    WHERE 1 = 0 is not always a debugging construct. Eg. SELECT ... INTO #SomeTable WHERE 1 = 0 Creates an empty temp table with the desired structure (as defined in the SELECT).

    have you ever tried to get an estimated execution plan for performance tuning with a "select into" in the proc? the optimiser just throws an error about invalid object #sometable

    It's on our coding standards list as "annoys the DBA when he has to improve performance" 🙂

    right above "forgetting to remove your debug code will exclude you from the free cakes the DBA makes for you"

    all of our guys have the redgate tools, if you write a "Select * into", hover over it, then it will allow you to generate a CREATE #Table script and convert it into

    create table #x

    insert into x select * from ....

    one of the most useful features of toolbelt i have used in the past week

     

    MVDBA

  • I think it is a ridiculous waste of time when someone comments on the obvious, like:

    counter++;   // increment counter

    Really??

  • MVDBA (Mike Vessey) wrote:

    ...

    all of our guys have the redgate tools, if you write a "Select * into", hover over it, then it will allow you to generate a CREATE #Table script and convert it into create table #x insert into x select * from .... one of the most useful features of toolbelt i have used in the past week  

    Is this in Prompt? I just tried with this query and it does not seem to do a complete job:

    DROP TABLE IF EXISTS #SomeTable;

    SELECT TableName = t.name
    ,SchemaName = SCHEMA_NAME(t.schema_id)
    INTO #SomeTable
    FROM sys.tables t
    WHERE 1 = 0;

    2019-06-05_09-13-13

    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.

  • My formative years of programming I used an ASCII facepalm art as the header block.

    I felt it gave a good indication of what anyone might expect if they proceeded further.  Y'know, managing expectations...

    Thankfully (sadly...) that system and all the code is now long gone.

     

    I am guilty of venting sometimes in code. Particularly relating to poor decisions outside of my control that lead to certain coding choices.

    And in hindsight gives some insight into why a particularly convoluted piece of code exists.

  • I would take Where 1 = 0 any day over what I saw:

    AND contactid is null

    (several other conditions)

    AND contactid is not null

    (a couple more conditions)

     

    Someone did that without a comment to disable a query.  When we wanted to enable it again, after I finally found this code,  I had to figure out which way was correct.

    • This reply was modified 5 years, 1 month ago by  nguntert.

Viewing 15 posts - 136 through 150 (of 156 total)

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