|
Non-representative line
Last post 09-03-2008 10:49 AM by jspenguin. 24 replies.
-
08-19-2008 1:26 PM
|
|
-
-
-
sibtrag


- Joined on 03-09-2007
- Posts 32
|
Re: Non-representative line
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.
|
|
-
-
Kurgan


- Joined on 08-19-2008
- Italy
- Posts 7
|
Re: Non-representative line
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.
|
|
-
-
morbiuswilters


- Joined on 01-15-2008
- East Coast Represent!
- Posts 4,990
|
Re: Non-representative line
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.
|
|
-
-
havokk


- Joined on 07-24-2008
- Christchurch, New Zealand
- Posts 30
|
Re: Non-representative line
morbiuswilters: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...
|
|
-
-
sibtrag


- Joined on 03-09-2007
- Posts 32
|
Re: Non-representative line
morbiuswilters:$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.
|
|
-
-
Erick


- Joined on 08-18-2006
- South Carolina
- Posts 46
|
Re: Non-representative line
morbiuswilters:$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
|
|
-
-
SenTree


- Joined on 04-03-2008
- Posts 116
|
Re: Non-representative line
sibtrag: morbiuswilters:$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
|
|
-
-
Nelle


- Joined on 11-08-2007
- graz.at.earth.milkyway.universe
- Posts 285
|
Re: Non-representative line
SenTree: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 */ ) { [...] }
|
|
-
-
Sunstorm


- Joined on 08-14-2005
- Posts 220
|
Re: Non-representative line
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.
"Most .NET applications require a persistent class representing felines." -- NHibernate
|
|
-
-
morbiuswilters


- Joined on 01-15-2008
- East Coast Represent!
- Posts 4,990
|
Re: Non-representative line
sibtrag: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.
|
|
-
-
morbiuswilters


- Joined on 01-15-2008
- East Coast Represent!
- Posts 4,990
|
Re: Non-representative line
Erick: morbiuswilters:$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.
|
|
-
-
SenTree


- Joined on 04-03-2008
- Posts 116
|
Re: Non-representative line
Nelle: SenTree: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;
|
|
-
-
DogmaBites


- Joined on 07-15-2008
- Posts 47
|
Re: Non-representative line
Erick: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.
|
|
-
-
Erick


- Joined on 08-18-2006
- South Carolina
- Posts 46
|
Re: Non-representative line
DogmaBites:So, your debugger didn't have conditional breakpoints? That's unfortunate.
I'm just lazy. You get to choose which is more unfortunate.
|
|
-
-
Carnildo


- Joined on 03-30-2005
- Posts 742
|
Re: Non-representative line
DogmaBites: Erick: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.
|
|
-
-
Isuwen


- Joined on 01-31-2006
- Posts 67
|
Re: Non-representative line
Carnildo: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.
|
|
-
-
tster


- Joined on 04-11-2006
- Natick, MA
- Posts 1,765
|
Re: Non-representative line
Carnildo: DogmaBites: Erick: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?
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting... see bio for the earth shattering ending.
|
|
-
-
Carnildo


- Joined on 03-30-2005
- Posts 742
|
Re: Non-representative line
tster: Carnildo: DogmaBites: Erick: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.
|
|
-
-
Kermos


- Joined on 12-16-2004
- Posts 132
|
Re: Non-representative line
Isuwen: Carnildo: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. So? What if you're debugging something that has to chew through a few ten thousand iterations before the error occurs and that even without the debugger can some time to complete? Speed can matter even when debugging. And honestly, I find an if statement sometimes to be more convenient than to click through IDE windows in order to try to get my breakpoint condition right.
|
|
-
-
KenW


- Joined on 07-19-2005
- Posts 429
|
Re: Non-representative line
Kermos:Speed can matter even when debugging. And honestly, I find an if statement sometimes to be more convenient than to click through IDE windows in order to try to get my breakpoint condition right. I can't believe your code skills are bad enough that you actually feel the need to try and defend optimization of debugging code. You should really learn to use your IDE, and your brain. There are much better things to spend your time on than debugging optimization, like writing code that actually works.
|
|
-
-
tgape


- Joined on 07-16-2008
- Posts 473
|
Re: Non-representative line
KenW: Kermos:Speed can matter even when debugging. And honestly, I find an if statement sometimes to be more convenient than to click through IDE windows in order to try to get my breakpoint condition right. I can't believe your code skills are bad enough that you actually feel the need to try and defend optimization of debugging code. You should really learn to use your IDE, and your brain. There are much better things to spend your time on than debugging optimization, like writing code that actually works.
Would you say it's a problem to optimize ones data, to cause the breakpoint to hit sooner? I ask, as that's what I tend to do here. I don't think I've ever encountered a situation where I needed to run through a loop section more than 100 times to get to a particular scenario.
That *having* been said, using a construct such as 'if (const == variable) { noop; }' to be able to break when one wants to actually takes far less brain power for some people than conditional breakpoints - especially in some IDEs I've seen, that make them far too complicated. No, I can't cite a reference; I'm repressing it.
tharpa:The "Reveal Codes" feature alone makes it better than Word.
QFT.
|
|
-
-
KenW


- Joined on 07-19-2005
- Posts 429
|
Re: Non-representative line
Sorry for the delayed response. Nasty little crunch this week to get something done by September 1st. tgape:Would you say it's a problem to optimize ones data, to cause the breakpoint to hit sooner? I'm not sure how you would "optimize data", but if that means "reduce the amount of data you have to process" to get to the breakpoint faster, then sure. I had code a while back to process a large (> 1GB) text file in a really nasty format. The code would blow up about 3/4s through, and obviously that would have been a pain to debug using just a breakpoint. So I put in code to show enough relevant data to identify the location in the file when it exploded, and ran it again. I then created a copy of the file, deleted most of the data (maintaining structure) before that location, and set a breakpoint there. I'm not sure you'd call that "optimizing" data, though. tgape:That *having* been said, using a construct such as 'if (const == variable) { noop; }' to be able to break when one wants to actually takes far less brain power for some people than conditional breakpoints - especially in some IDEs I've seen, that make them far too complicated.
Agreed, although we primarily use CodeGear's RAD Studio (Delphi and C++ Builder) here; Delphi allows inline assembly, so a simple block like if (SomeVariable = SomeValue) then asm int 3 end; works to trigger the debugger with a single line of code and a two second compile.
|
|
-
-
jspenguin


- Joined on 01-15-2006
- Posts 55
|
Re: Non-representative line
SenTree: Nelle: SenTree: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; I have seen the following form used:
void iDoNotUseParams( int p1, void * p2 ) { (void)p1; (void)p2; }
This makes it fairly clear.
sexp? t!
|
|
Page 1 of 1 (25 items)
|
|
|