Non-representative line



  • Most of the code in this program has better comments than this:



    oFont.setName("Palatino Linotype"); //MS Sans Serif



  • //This is not a comment



  •  I must admit I've been guilty of that sort of comment.  I usually preface it with the word "was" to make the intent more obvious, though.



  • Nice. I see these sort of things all the times. Code gets changed, but comment is forgotten. After all, comments are useless to the machine. But anyway, who needs a comment that says the name of the font that has just been stated in the code? Or maybe that comment is both correct and needed since on that machine the Palatino Linotype font file actually contains the MS Sans Serif font.



  • I can beat that: 

    $var = $var; // NEEDS ATTENTION: may have been used for some specific purpose



    The code does precisely what you think it does -- nothing.  Somebody added the comment later because they weren't sure if they should delete the code or not.  This line was not representative of the general codebase, either.  For one, it was actually commented, even if the comment was a Zen koan.  Second, even though the code itself was completely useless, it didn't: corrupt data, expose credit card numbers or send a list of every user under the age of 13 to a pedophilia mailing list.  Thus, it was technically less harmful than 90% of the remaining code.



  • @morbiuswilters said:

    Thus, it was technically less harmful than 90% of the remaining code.

    I'm not sure whether to laugh or cry at that last sentence. I decided that since its not my codebase, laughter is appropriate. Nervous laughter...



  •  @morbiuswilters said:

    $var = $var; // NEEDS ATTENTION: may have been used for some specific purpose

    Could this be Perl?   In that case it would prevent the interpreter from complaining that  $var was only referenced once.



  • @morbiuswilters said:

    $var = $var; // NEEDS ATTENTION: may have been used for some specific purpose

    I've used something similar for debugging a specific section of a loop:

    if (number == 2010)
    number = 2010; // Breakpoint here



  • @sibtrag said:

     @morbiuswilters said:

    $var = $var; // NEEDS ATTENTION: may have been used for some specific purpose

    Could this be Perl?   In that case it would prevent the interpreter from complaining that  $var was only referenced once.

    That was my thought, I use the same technique in C when I have a set of functions with identical parameters, where not all functions actually use all parameters.

    My comment is usually more helpful, though: // Stop compiler whingeing



  • @SenTree said:

    That was my thought, I use the same technique in C when I have a set of functions with identical parameters, where not all functions actually use all parameters.
     

    i think this works as well : 

    void iDoNotUseParams( int /* p2 /, void * / p2 */ )

    {

    [...] 



  • I'm almost certain that it's copypaste laziness. It's more obvious when you think of it as...

    oFont.setName( "Palatino Linotype" );
    //oFont.setName( "MS Sans Serif" );

    The original writer was probably trying to find a good font (or was asked to change it), and he left the comment there as a way of not having to look up the exact spelling, capitalization, etc. of "MS Sans Serif", in case Palatino Linotype doesn't work out.



  • @sibtrag said:

    Could this be Perl?   In that case it would prevent the interpreter from complaining that  $var was only referenced once.

    No it wasn't perl.  Also, you can ignore the stupid "variable referenced once" errors in perl, which would make way more sense. 



  • @Erick said:

    @morbiuswilters said:

    $var = $var; // NEEDS ATTENTION: may have been used for some specific purpose

    I've used something similar for debugging a specific section of a loop:

     

    if (number == 2010)
    number = 2010; // Breakpoint here


    No, that's not what it was for. 



  • @Nelle said:

    @SenTree said:

    That was my thought, I use the same technique in C when I have a set of functions with identical parameters, where not all functions actually use all parameters.
     

    i think this works as well : 

    void iDoNotUseParams( int /* p2 /, void * / p2 */ )

    {

    [...] 

    I think it probably would; either method is valid C. However, our coding guidelines (based on MISRA) specify that all function parameters shall be named, and that the identifiers in the declaration and definition shall be identical, but they say nothing about lines of the form x = x;



  • @Erick said:

    I've used something similar for debugging a specific section of a loop:

     

    if (number == 2010)
    number = 2010; // Breakpoint here

    So, your debugger didn't have conditional breakpoints?  That's unfortunate.



  • @DogmaBites said:

    So, your debugger didn't have conditional breakpoints?  That's unfortunate.

    I'm just lazy. You get to choose which is more unfortunate.



  • @DogmaBites said:

    @Erick said:

    I've used something similar for debugging a specific section of a loop:

     

    if (number == 2010)
    number = 2010; // Breakpoint here

    So, your debugger didn't have conditional breakpoints?  That's unfortunate.

    Depending on the debugger and computer architecture, a breakpoint on an "if" statement can be several orders of magnitude faster than a conditional breakpoint.



  • @Carnildo said:

    Depending on the debugger and computer architecture, a breakpoint on an "if" statement can be several orders of magnitude faster than a conditional breakpoint.

     

    But you're... debugging.



  • @Carnildo said:

    @DogmaBites said:

    @Erick said:

    I've used something similar for debugging a specific section of a loop:

     

    if (number == 2010)
    number = 2010; // Breakpoint here


    So, your debugger didn't have conditional breakpoints?  That's unfortunate.

    Depending on the debugger and computer architecture, a breakpoint on an "if" statement can be several orders of magnitude faster than a conditional breakpoint.
     

    "several orders of magnitude."   O RLY?



  • @tster said:

    @Carnildo said:

    @DogmaBites said:

    @Erick said:

    I've used something similar for debugging a specific section of a loop:

     

    if (number == 2010)
    number = 2010; // Breakpoint here


    So, your debugger didn't have conditional breakpoints?  That's unfortunate.

    Depending on the debugger and computer architecture, a breakpoint on an "if" statement can be several orders of magnitude faster than a conditional breakpoint.
     

    "several orders of magnitude."   O RLY?

    It's been a while since I've debugged anything on a 80486 using Microsoft C/C++ 7, but yes.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.