|
Just got off the blower to a colleague who is having a very bad day
He got a call from a customer whose database seems to have disappeared; now my colleague isn't a technical guy, but I talked him through SQL Server Management Studio. Suprisingly, my collegaue confirmed that the database was present, as was it's entire structure - only all the tables were empty of data.
I asked him the background to the call - as this isn't a system I know much about or deal with. Apparently this database back ends a VB6 application, and one of the features of this 'application' is that it allows users to import data from 'sattelite' Access databases. Like a lead balloon the penny dropped and I remembered why i stopped having anything to do with the system 2 - 2 1/2 years ago.
I asked, "have you got a copy of the last Access database imported"? "Yeah sure," he said as I could feel the laughter rising. I opened Access, and sure enough the imported database was also completely empty I advised to restore last night's backup, while I had a word with our VB *guru*. The conversation went a bit like this:
Me: Remember 2 1/2 years ago I told you your import routine was cretinous? That blindly dropping tables and then recreating them from an unknown, untrusted source is possibly the worst bit of design I have ever encountered? That you are a complete Charlie?
Him: <thinks> Oh, yeah!
Me: Well why didn't you fix it!!!!!!
Him: Err... well... you see... I still thought it was the best way of doing it!
BWHAHAHHAHAHHAHABBAHAHHAHAHHAHAHAHHAHAHAHHAHA!! HAHAHHAHAHAHHAHAHAHHA BWHWHWHWHWWHHWWHAHAHAHAHAHAHAHAHAHA HAHAHAHA!
VB6 Chumps - they should all have their computers taken away from them and be given Etch-a-Sketchs instead!
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
|
There you go. Classic schoolboy error there. VB Guru (isn't that an Oxymoron - or at lease a moronic Ox). Expecting them to think. Tie the two sentences together and you've got the makings of a Bruce Willis movie.
|
|
|
|
|
martin_hughes wrote:
Just got off the blower to a colleague who is having a very bad day
I'm glad I'm not one of your colleagues whose suffering inspires much mirth in you.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Oh, no!...
I have to admit to resembling that remark, however, as I am forced to use VB (usually VBA) on occasion.
|
|
|
|
|
But couldn't this have happened with any programming language, not just VB?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, quite true, but it has been my experience of C++/Java/C# guys who claim to 10-15 years working with their chosen languages (as does our resident VB "Guru", apparently) that they approach software with a bit more thought
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
I get your point, but...
martin_hughes wrote: C++/Java/C# guys who claim to 10-15 years working with their chosen languages
... would make me a bit hesitant about the trustworthiness of that C# guy.
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
Good catch - or the Java guy claiming 15 years
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Today we had to edit very old code and we ran into this great piece of code
for (int lnIndice = 1; lnIndice <= 1; lnIndice++)
{
switch (lnIndice)
{
case 1:
break;
}
}
We found it very funny
|
|
|
|
|
It would be interesting if the optimizer managed to do anything with this. This is the kind of stuff you end up with, when code gets 'maintained' over a couple of generations of developers.
|
|
|
|
|
Effectively, and no one changed it
|
|
|
|
|
|
The loop one times construct can be useful.
Where I've used it is when I've had to work with a long sequence of if else/if's, and used break to exit. For instance:
while (true)
{
if (set (ifrFragment))
{
result = true;
ifrTerm = ifrFragment;
break;
}
if (errorCode)
break;
if (keyword (TokenSubtype::Not) && term (ifrFragment))
{
result = true;
ifrTerm = TokenSubtype::Not.asString() + " " + ifrFragment;
break;
}
if (errorCode)
break;
break;
}
But the switch/case in your example would lead me to believe that lnIndice had other values at some point, perhaps for debugging.
|
|
|
|
|
lol. Haven't seen that done in a long time. We used to do it to piss off the "never use goto" zealots years ago when forbidden to use 'goto xit' for handling error conditions.
|
|
|
|
|
Robert Surtees wrote: We used to do it to piss off the "never use goto" zealots years ago when forbidden to use 'goto xit' for handling error conditions.
Robert, I use goto's for exactly the same reason.
if (keyword (TokenSubtype::Group))
{
if (!group_label (groupName))
{
errorMessage = myName + ": Missing GROUP label\n" + errorMessage;
errorCode = DL_ERROR;
goto exit_;
}
if (!separator (TokenSubtype::Colon))
{
errorMessage = myName + ": Missing colon following GROUP label";
errorCode = DL_ERROR;
goto exit_;
}
|
|
|
|
|
I use goto only to break out of >1 nested loops... Don't see the need for it anywhere else...
|
|
|
|
|
The rollback from a list of initialization steps maybe another valid usage.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
I aint affraid to use it bubba joe I just don't see the need for it... At least in C#...
|
|
|
|
|
C#? Sounds like a language for quiche eaters.
Seriously, there are times when nested if/else constructs get unweildy. In some cases, albeit rarely, I'd rather use a goto. I only use them to transfer control either to a error handling section or a single exit point.
|
|
|
|
|
Tony Wesley wrote: I use goto's
It's OK, so do I, in C#!
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
So what happens to your "goto" cleanup routine when an exception is thrown?
I'll give you a hint -- it doesn't get called.
|
|
|
|
|
CurtD wrote: So what happens to your "goto" cleanup routine when an exception is thrown?
I'll give you a hint -- it doesn't get called.
The goto doesn't figure into that. Just above it in the thread is another snippet of my code that doesn't use a goto.
Same issue. What happens to the code after the while loop when an exception is thrown? It doesn't get executed.
Once could argue that the problem is with exception. As I pointed out elsewhere, Joel Spolsky argues that exceptions [...] create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's: (emphasis added)
I don't quite agree with Joel. But there was a time, when I was debugging an app that another programmer had written, that I understood that completely. It was spaghetti exception handling. I never knew where I had come from.
I'm not saying you shouldn't use exceptions. But they can be abused as badly as gotos.
|
|
|
|
|
Tony Wesley wrote: The goto doesn't figure into that. Just above it in the thread is another snippet of my code that doesn't use a goto.
Same issue. What happens to the code after the while loop when an exception is thrown? It doesn't get executed.
Once could argue that the problem is with exception. As I pointed out elsewhere, Joel Spolsky argues that exceptions [...] create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's: (emphasis added)
I don't quite agree with Joel. But there was a time, when I was debugging an app that another programmer had written, that I understood that completely. It was spaghetti exception handling. I never knew where I had come from.
I'm not saying you shouldn't use exceptions. But they can be abused as badly as gotos.
I'm talking about the case where coders like to put a block of cleanup code at the bottom of a method and "goto" it when something goes wrong or fall into it in a non-error situation. If you are depending on blocks of cleanup code, an exception will bypass it completely. This worked back in C, but not in OO design.
That's why I use objects that clean themselves up when destroyed -- automatically. I am far too lazy to try to figure out every possible error situation, catch exceptions from anything that might throw them, and ensure that there is an appropriate goto.
I disagree completely with Joel Spolsky. He suggests using return codes instead of exceptions. Return codes and exceptions are completely different things. Exceptions are not meant to be return codes. They are "exceptional" situations where usually the app cannot continue. And exceptions have the major advantage of unwinding the stack, which he fails to mention. They are not "an abrupt jump from one point of code to another."
It seems like OO programming has really failed to catch on with a lot of developers.
modified on Sunday, December 16, 2007 12:10:46 AM
|
|
|
|