|
Super Lloyd wrote: #warning super cali fragilistic expi ali docious
If my code would be in C#, I would use the #warning pragma
int __todo; is the only way I've found that works between different C++ compilers.
|
|
|
|
|
It's a subtle hint... It really means "I won't fix this until I receive my check"
|
|
|
|
|
Eh... i'm feeling with you, 50% of the project i'm working on was like this.
|
|
|
|
|
I'm glad he put the exclamation marks in there. That made me realise this wasn't just another comment, it was something important that I can't ignore.
Maybe IDEs should include a feature that allows you to scan for comments that include exclamation marks, because that means they must be important! And comments in upper case with two exclamation marks must be really IMPORTANT!! In fact, this comment must be incredibly important because it has an uppercase IMPORTANT!! and three exclamation marks in total!
Too bad it wasn't important enough to fix.
|
|
|
|
|
> Maybe IDEs should include a feature that allows you to
> scan for comments that include exclamation marks, because > that means they must be important!
IDE's do have that feature, although Visual Studio went with the needlessly verbose 'TODO' rather than the more pithy !
I wonder what percentage of Visual Studio programmers know that it has a Task List feature?
Might make a good interview question actually.
|
|
|
|
|
Unfortunately, in VS, the Task List for TODOs is glitchy and doesn't show everything. If you use R#, it has a much better To-Do explorer that includes TODOs, NOTEs, and my favourite NotImplementedExceptions!
|
|
|
|
|
GibbleCH wrote: the Task List for TODOs is glitchy and doesn't show everything
I'm pretty sure you have to have the file open to see the TODO comments in the task list.
|
|
|
|
|
Actually, the task list is token-based, defined from the Tools->Options->Task List->Tokens panel.
For interest's sake, I just tried to add !!! as a token name. No love (invalid chars).
IMPORTANT, however, just turned up three more instances...
|
|
|
|
|
Yes, I'm also familiar with NetBeans and Eclipse in the Java world, both of which allow you to put comments in like TODO or FIXME or indeed anything you want and associate that with a priority in the task list. There is also Checkstyle which is a Java tool for checking source code and one of the things it can scan for is TODO comments, etc.
It just happens to be a personal bug-bear for me, the way developers throw exclamation marks all over the place. How often have we seen error messages like:
File not found!
What exactly is the developer trying to convey to the user by including that exclamation mark? The file was not found - surprise! Or maybe: The file was not found - Oh My God! Or: The file was not found - HA HA HA!
|
|
|
|
|
David,
I don't know about anyone else, but you've convinced me.
A bit of work to do over the weekend, but by Monday my coding standards will have a new section called Smilies!
' File Not Found
' File Not Found
' File Not Found
' File Not Found
' File Not Found
I'm amazed this isn't standard practice already.
-Richard
|
|
|
|
|
I love it! Being on holliday, i can't wait to get back to implement this wonderful scheme.
- turin
|
|
|
|
|
Great idea! I will have to suggest that my company implement that new standard for error messages
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
int g = 0;
_more:
while(1)
{
g++;
if(g < 10)
goto _more;
else
goto _done;
}
_done:
printf("%d\n", g);
...byte till it megahertz...
|
|
|
|
|
True programming talent
|
|
|
|
|
There is no excuse for that.
|
|
|
|
|
You sir...have been topped.
int g = 0;
_more:
while(1)
{
g++;
switch (g)
{
case 0:
goto _more;
case 1:
goto _more;
case 2:
goto _more;
case 3:
goto _more;
case 4:
goto _more;
case 5:
goto _more;
case 6:
goto _more;
case 7:
goto _more;
case 8:
goto _more;
case 9:
goto _more;
default:
goto _done;
}
}
_done:
printf("%d\n", g);
Frankly, there could always be a worse.
|
|
|
|
|
WOW! The example by the OP was BAD, but this is worse.
I just glad the loop had only 10 iterations and not 10,000.
|
|
|
|
|
Thankfully, it's not real. I just took his code and applied the 'coding horror' found in the last posting here.
|
|
|
|
|
You never know something like that will pop up :/ and it will inadvertently will.
|
|
|
|
|
...byte till it megahertz...
|
|
|
|
|
Looks a little like duffs device which unlike the code above was actually useful in rare cases... before compilers started to apply the optimization automatically.
Oh and here's a nasty one I've actually seen:
while (1)
{
if (foo)
{
break;
}
if (bill)
{
break;
}
break;
};
|
|
|
|
|
That was not bad, it was very very bad
Andrew Rissing wrote: int g = 0;
_more:
while(1)
{
g++;
you started with g++, which has a value of 1, it will never be less than 1 then you do
Andrew Rissing wrote: switch (g)
{
case 0:
goto _more;
You may as well continue case 10, case 11 .......case 9999
|
|
|
|
|
I'm in tears from laughing at this.
|
|
|
|
|
Is this a real horror or an artificial one? I find it hard to believe someone can be so stupid...
|
|
|
|
|
Jeroen De Dauw wrote: I find it hard to believe someone can be so stupid...
... and not be using VB.
|
|
|
|