|
Sometimes I shake my head. Found this gem in some stuff I wrote 7 or 8 years ago.
Sleep(15);
I especially like the smiley in the comment.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
But it does sound like a splendid idea right now
|
|
|
|
|
I saw similar code recently, stuff running on another thread at the time.
It all worked wonderfully until someone ran it from an old, slow, low memory machine where the wait wasn't long enough!
Now where is the GoBackToSleepABitMore() command? It works on my kids.
|
|
|
|
|
Really.. You have to teach me that one. Mine get up at 6:00AM on weekends, even if I make it impossible for them to watch cartoons or play video games.
|
|
|
|
|
keep them up late on friday night usually works. of course you don't get enough sleep either way!
|
|
|
|
|
Hmmm. Did something similar a while ago when I wrote my first multithreading application. It was getting three datasets from a database and needed all three to finish before moving on. Initially, I had the sleep before I got the threads to synchronise properly. However, I forgot to take the sleep out. Application went into Production and only after a complaint a few months later did I investigate and find the gem.
Good thing was that I looked like a hero because I made the application so much quicker. One of these days I'll own up!
|
|
|
|
|
Nah, those are the things we build our reputations on.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
I had an occasion where Sleep() was required to make something work. We had a third-party library we used to communicate with some USB hardware. The library didn't synchronize properly with the device driver, so you had to follow your calls to the library with Sleep() calls of various durations .
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: The library didn't synchronize properly with the device driver, so you had to follow your calls to the library with Sleep() calls of various durations.
Hmmm, (pondering whether this Sleep() will fix a BlueTooth sync problem we're experiencing....)
Gary
|
|
|
|
|
[Showing my age!] I remember back when the PC AT came out, with a (WOW!) 80286 clocked at 6 Mhz. You had to write two NOPs after every OUT instruction, I think it was. Otherwise the I/O bus got its tits in a tangle.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
When a debug message conveys Relief, you're probably
on thin ice.
dbg('Function returning true...');
dbg('Whew.... Its your baby now - messaging');
-Rd
|
|
|
|
|
Similar to this one
TRACE("Shouldn't be able to reach this code! But good luck, though.");
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
MsgBox( "Oops." ) I found this one in something I wrote in my first job out of school.
|
|
|
|
|
I used to do that alot in crazy if else statements that shouldn't have been needed:
Response.Write("Something has gone seriously wrong here, please reboot universe")
|
|
|
|
|
I use a throw with a similar message - mostly on the default of a switch
|
|
|
|
|
Yes, that kind of thing is always a bad sign. Not that I ever did such a thing when I started out!
I do make sure to avoid doing such things now.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
In my first job I was working alongside some guys from an external vendor. Integrating their system into ours and trying to get the whole thing validated by System Test.
One day an error popped up that originated in the Vendors Code:
"The System Has Gone Pear Shaped"
System test weren't impressed.
The guy from the external vendor was summoned, and asked what a more accurate error message would be. I can't remember what it was, but he gave a very detailed, accurate and completely unintelligible response.
To which the head of system test replied...
"And what does that mean? In English?"
To which he replied...
"The system has gone pear shaped."
-Rd
|
|
|
|
|
At which point, you take the vendor outside the building, put two bullets in his head, and leave his body mounted on a pike outside the castle walls as a warning to others.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: At which point, you take the vendor outside the building, put two bullets in his head, and leave his body mounted on a pike outside the castle walls as a warning to others.
Actually that particular project I had no problem with the Vendor. I was young Naive, what did I know?
I'll say this. Compared to experiences I've had and am still having with vendors, that project was a cakewalk.
When you've debugged a vendor's Javascript files you start to understand that a dodgy error message is no biggie.
There's nothing quite like javascript files which seem to have had all whitespace sucked out of them, presumably to stop people stealing some of the most horrible code ever written (why would anyone want to).
-Rd
|
|
|
|
|
for(i = 0; i < num; i++)
{
strIntString.Format(_T("%3d,%#9.*f,%#9.*f,%#9.*f,%#9.*f,%#6.*f,%#6.*f,%#6.*f,%#6.*f,%02d:%02d:%02d,%3d,%4d,%1d,%5d,%1d,%3d\r\n"),
newObject->m_nIndex,
temp.prec[0], newObject->val1[0], temp.prec[1], newObject->val1[1],
temp.prec[2], newObject->val1[2], temp.prec[3], newObject->val1[3],
temp.prec2[0], newObject->val2[0], temp.prec2[1], newObject->val2[1],
temp.prec2[2], newObject->val2[2], temp.prec2[3], newObject->val2[3],
newObject->m_nHours, newObject->m_nMinutes, newObject->m_nSeconds,
newObject->m_nNext, newObject->m_nTotal, newObject->m_nGroup,
newObject->m_Extra, newObject->m_nMode, options);
numOut=strIntString.GetLength();
m_File->Seek(HEADERLEN+(105*i),CFile::begin);
m_File->Write(strIntString,numOut);
strIntString.Empty();
}
Guess what happens when any of the variables has more digits than was allocated in the Format call. Right, the line is no longer "EXACTLY" 105 bytes. File becomes a messy pile of bytes.
The only thing I changed from the actual code were the variable names. This is in production code, currently being run by thousands of customers.
You should see how these files are read in. It's worse, but too long to post.
Sigh.
He said, "Boy I'm just old and lonely,
But thank you for your concern,
Here's wishing you a Happy New Year."
I wished him one back in return.
|
|
|
|
|
David Kentley wrote: when any of the variables has more digits than was allocated in the Format call
Does that ever actually happen?
|
|
|
|
|
aspdotnetdev wrote: Does that ever actually happen?
Yes, as I discovered today when I had to track down a customer reported bug. It is an usual case, but it's completely possible and even legitimate. I had no idea what I would find under the rock I kicked over.
He said, "Boy I'm just old and lonely,
But thank you for your concern,
Here's wishing you a Happy New Year."
I wished him one back in return.
|
|
|
|
|
rewrite it in COBOL, it's good at that sort of stuff
|
|
|
|
|
Such constructs aren't so rare... in a company I worked years ago, we had to import lots of different file formats, and I'd say, 50% of them used a similar "design". Not to mention that our fantastic database also almost worked like that - yay! No wonder that company doesn't exist anymore.
|
|
|
|
|
Doesn't the fact that the company is now defunct mean that such constructs are, at least, getting rarer...?
|
|
|
|