|
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.
|
|
|
|
|
Weeeelll - it was meant to be - the programmer assumed that if they were printing they would want one or more copies - what was really missing was some validation in the GUI to prevent them selecting zero copies (I mean, why would you want to select to print zero copies?)
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
|
I seem to remember (it's been a while ) that Cobol didn't have a For loop.
In fact all loops used Perform... constructs.
There was a Perform Varying - which is like a For
In fact there wasn't a While.. or Do.. either - it was all
Perform Until... or Perform ... Until.
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
maxxx# wrote: the programmer assumed
See, there's the problem.
But if the spec says to do that, then it's OK and you can blame it on the monkey who wrote the spec.
Ideally, the programmer would ask for clarification (in an email), and then take a break awaiting a response, however long that takes.
But this is clearly a case in which while is the proper construct.
Oh...
maxxx# wrote: why would you want to select to print zero copies
To just save the file on disk. I seem to recall this in a system I had to support a bunch of years ago. The PRINT program would generate a report file, which it could then print. Oh, right, it was a VAX/VMS system, so the file got spooled to a print queue, not sent to the printer directly. As I recall, saying 0 for copies, or 0 for paper type would indicate that you didn't want to print it.
Bonus: Even though VAX/VMS allows a print job to specify the number of copies as 1 to 255, this PRINT program only allowed up to 20 . One of the users needed 80 copies of a particular report, so she ran it four times, each time having to get the input just right. Eventually I realized what she was doing. Because we had the source code (VAX BASIC ) I was able to change the program to allow the full 255 copies.
|
|
|
|
|
PIEBALDconsult wrote: you can blame it on the monkey who wrote the spec.
How did you know it was the monkey?
PIEBALDconsult wrote: Ideally, the programmer would ask for clarification (in an email), and then take a break awaiting a response, however long that takes.
This was in the days before email! Indeed, in the days before taking breaks!
PIEBALDconsult wrote:
To just save the file on disk. I seem to recall this in a system I had to support a bunch of years ago. The PRINT program would generate a report file, which it could then print. Oh, right, it was a VAX/VMS system, so the file got spooled to a print queue, not sent to the printer directly. As I recall, saying 0 for copies, or 0 for paper type would indicate that you didn't want to print it.
That's just a case of extremely poor UI - why not have a Save and Save and Print option - or something more obvious to show theuser what is happening - selecting zero copies isn't really intuitive to save a file!
Oh - and on the system this was written on (TI 990) you could select the number of copies in the spooler - so in fact there was no need for a loop at all!
Take a chill pill, Daddy-o
.\\axxx
(That's an 'M')
|
|
|
|
|
maxxx# wrote: extremely poor UI
Yeah, well the system was developed in Roswell, New Mexico, so all bets are off.
|
|
|
|