|
Good to see C# is equally vulnerable. I thought of cargo cult programming as the ritual inclusion of code or program structures that serve no real purpose. Locking an algorithm against changes of it's variables is perfectly valid but in this app no external algorithm ever tried to acquire the critical section. (The original code contains public accessors for the lock, i removed them to check if they are used at all. Turned out they were unused...)
|
|
|
|
|
Maybe the author did have intention of using reference:
T __fastcall operator *()
{
EnterCriticalSection(&CS);
T value = data;
LeaveCriticalSection(&CS);
return value;
}
|
|
|
|
|
LOL, some people think randomly sprinkling locks into the code will make it thread safe
|
|
|
|
|
Freekin' maintenance coding...
foreach (string item in items)
{
server.Remove(item);
}
|
|
|
|
|
I thought everybody knew compilers can read comments and act accordingly...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Probably meant to go back and check for it's existence in the server collection prior to attempting to remove it...
This is why you use //TODO: instead of just generic comments so you can find them all before release!
|
|
|
|
|
I use an "int __todo_description;" instead. Gives me a compiler warning. Now I only need to get rid of these 205 warnings
|
|
|
|
|
easier:
#warning super cali fragilistic expi ali docious
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
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.
|
|
|
|