|
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...?
|
|
|
|
|
Only in theory. For every horrible coder out of the race two new ones come to replace him. And the odds are good that the one who did this is still at large somewhere out there.
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
It's enough to make ya cry into your beer...
P.S. I like your sig.
|
|
|
|
|
At least that block of code had line breaks. Just imagine trying to read that as one continuous line...
I find the best way to have a positive attitude is to have extremely low expectations
|
|
|
|
|
Sometimes you just have to hope for the best until you get the next job - at least, this was the credo of more than one programmer who I've met in person or simply in the trash they left behind
|
|
|
|
|
I had something similar in production to fix.
File had fixed length lines, every column meant something and couldn't change.
But it did, suddenly some lines were one char too long, so some columns were invalid.
A 2 char field was supposed to be 01, 02, or 03. An int was being used to calculate,
and got incremented up to 98, 99, 100, .... More than 2 characters. The program was
using C char* with strcpy and strcat, so this field being too long shifted the position
of all following fields, bad data!
I corrected the field to only be 1, 2 or 3 (zero prepended to make 2 chars), and added
checks for the line length before outputting to a the required file. And starting
using C++ class std::string instead of char* in my newer code to help my sanity.
|
|
|
|
|
This gem was on the asp.net forums:
if (Session["_serial"] + "" == "")
Response.Redirect("menu.aspx", true);
Steve Wellens
|
|
|
|
|
At first I thought it looked ugly, but actually you can add a null to an empty string and the output will be an empty string. Also, adding two empty strings together produces an empty string, so what this code does is checks if the string Is Null Or Empty, very clever
|
|
|
|
|
Sam Cragg wrote: At first I thought it looked ugly,
It is ugly.
Sam Cragg wrote: very clever
Maintaining simple code is cheaper than maintaining 'clever' code.
if (String.IsNullOrEmpty(Session["_serial"] as String))
Response.Redirect("menu.aspx", true);
if ((Session["_serial"] == null) || (Session["_serial"] == ""))
Response.Redirect("menu.aspx", true);
String _serial = Session["_serial"] as String;
if (String.IsNullOrEmpty(_serial))
Response.Redirect("menu.aspx", true);
Steve Wellens
modified on Thursday, September 16, 2010 9:17 PM
|
|
|
|
|
Sorry, I was trying to be sarcastic (the winking smiley?), as I said:
checks if the string Is Null Or Empty
Hinting at the built in function string.IsNullOrEmpty
|
|
|
|
|
It is rather clever if it is dotNet1.1 where string.IsNullorEmpty doesn't exist. I would probably suggest that a dev write it in a more legible way though so that their code wouldn't end up here.
|
|
|
|
|
If it's checking to see if the session object is null or empty, that seems perfectly cromulent.
|
|
|
|
|
Cromulent
Used in an ironical sense to mean legitimate, and therefore, in reality, spurious and not at all legitimate.
Assumes common knowledge of the inherent Simpsons reference.
Excellent choice of words, I have to remember this one...
V.
|
|
|
|
|
Your prose will be the better for it.
|
|
|
|
|
IIRC it's an idiom commonly used in classic ASP to get rid of unwanted nulls when getting data from ADODB Recordset (nulls are quite tricky to test for in ASP3):
field = rs("field") & ""
or
field = CLng("0" & rs("field"))
Seems like some programmer out there has some nostalgy...
Luca
The Price of Freedom is Eternal Vigilance. -- Wing Commander IV
En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur.
(But the best thing God has created, is a New Day.)
-- Sigur Ròs - Viðrar vel til loftárása
|
|
|
|
|
Luca Leonardo Scorcia wrote: Seems like some programmer out there has some nostalgy...
It's not just nostalgia. If you move from a language that doesn't have a feature into one that does,
it can take quite a while to "discover" that feature. You've got a solution that works.
To my shame I only recently discovered (thanks to someone on CodeProject correcting me) that you can add methods to structs.
I've been using them as simple data structures for so long that it never crossed my mind to see if I could add methods and
constructors.
-Rd
|
|
|
|
|
If this sort of thing was implemented as a function, and I mean a VERY well-documented function, it would be ingenuous (especially if it was inline, where this is permitted). Otherwise, cute constructs like this are a pain in the tailbone unless you only hire coders who instantly recognize every trick in the book. Good luck with that
|
|
|
|
|