|
Ummm, it is in the correct forum. The posted code is somewhat a horror.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
This post is definitely in the correct forum. The poster knows what is wrong with the code. The person that is new to try/catch/finally doesn’t realize it yet
|
|
|
|
|
Your programmer didn't learn try...catch as well as he thought he did.
Imagine that you are hired to build a bridge over a river. The river gets slightly wider every day; sometimes it shrinks but nobody can predict when. Your contract says you can't use concrete or steel - the client only provides timber and cut stone (but won't tell you what kind). Gravity changes from hour to hour, as does the viscosity of air. Your only tools are a hacksaw, a chainsaw, a rubber mallet, and a length of rope.
Welcome to my world.
-Me explaining my job to an engineer
modified on Thursday, June 26, 2008 11:26 AM
|
|
|
|
|
Robert Royall wrote: Imagine that you are hired to build a bridge over a river. The river gets slightly wider every day; sometimes it shrinks but nobody can predict when. Your contract says you can't use concrete or steel - the client only provides timber and cut stone (but won't tell you what kind). Gravity changes from hour to hour, as does the viscosity of air. Your only tools are a hacksaw, a chainsaw, a rubber mallet, and a length of rope.
Welcome to my world.
Very true. I like that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
"A little knowledge is a dangerous thing." -- Alexander Pope
|
|
|
|
|
Just to be pedantic - Pope's quotation is actually "A little learning is a dangerous thing"
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|
|
Since some experienced programmers like Dan Neely didn't get humor feeling from my post, I do need to add the following words at the bottom of my post:
(Hint: the programmer set ds = null in section finally before returning his ds)
|
|
|
|
|
You could edit your post.
Just make it clear(er) that you have already pointed out the error and are not asking for help.
|
|
|
|
|
I think a coding horror and a common mistake when misunderstanding the functionality of the language are often confused. Not reading the documentation is an entirely different problem!
If this developer had been coding for years, and only just come across try..catch..finally, then I would truly cry, but if this is a newbie, this is a case of being too harsh on your underlings (like the post the other day)
|
|
|
|
|
che3358 wrote: (Hint: the programmer set ds = null in section finally before returning his ds)
That was one of the first things I noticed
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
He should have learned try-catch-finally, not just try-catch.
|
|
|
|
|
che3358 wrote: A programmer student told me he just learned was just starting to learn try...catch
|
|
|
|
|
cause:
finally
{
ds = null;
}
|
|
|
|
|
I think we knew that already
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
A simple programming oversight.
So the creationist says: Everything must have a designer. God designed everything.
I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
|
|
|
|
|
How many bytes of text have I typed in my lifetime??? Man, I wish I kept track...
|
|
|
|
|
His purpose was to clear object DataSet in section finally. But, do you guys think the DataSet will be cleared if no error is caught?
private bool CheckData()
{
DataSet ds = null;
try
{
return true;
}
catch{}
finally
{
ds = null;
}
return false;
}
|
|
|
|
|
Uhh...yes? That's the entire point of the Finally... statement.
“Acer, Gateway, and eMachines are the same company now. Great! Now we just need a really big toilet, and we can get rid of all three at once.”
|
|
|
|
|
I'm busy with a database table that contains export definitions. Each record has an XML field that defines the actual export layout, but in order to properly serialise and deserialise this XML to a text file, I need to store other fields from the record in the XML itself.
|
|
|
|
|
I'd like to say, "then don't do it", but I'm curious to know more.
|
|
|
|
|
I'd just like to say "then don't do it".
Remember that cat!
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
I just remembered this one:
Programmer had job of writing report output - and the user could select the number of copies.
Do
PrintReport();
numberOfCopies = numberOfCopies - 1;
Until numberOfCopies = 0;
Worked fine in his testing, even passed system testing.
Then a user decided they didn't want to print after all and, instead of cancelling, selected 0 copies...
They replaced the paper in the printer twice before realising the same report was still printing.
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
when you found that did you get a metal image of the guys from the Guiness commercials saying "BRILLIANT!!", I have yet to find a use for a do..while loop, and continue to wonder what you really need them for.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
<pedantic>Well, maybe a mental image.
Would that we had Guinness commercials in this land of Aus!
Oh - and it was a Do..Until loop
And they're very useful when you want to do something at least once, and possibly more than once, but never never.
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
maxxx# wrote: they're very useful when you want to do something at least once
Yet the above code is not such a situation.
|
|
|
|