Learn IT

Free learning anything to everything in Information Technology.

We Developers Do the Dumbest Things

Ever do something really stupid in your code? I bet you can't say "No" with a straight face. But, don't you get irritated when you encounter someone else's blunders. I have found some real dillys lately and thought I might run them by anyone that ever reads my blog, which at this point is not a lot of people.

It seems that a lot of self-named .NET developers totally don't understand Exception Handling!

For example, explain the need for the following Try Catch block, if you can.

private void DoNothing()
{ try
{
// do some code
}
catch(Exception ex)
{
throw(ex);
}
}

Did it never occur to the writer of this code that if they had not coded the try catch, that the results of a failure in the DoNothing method will be exactly the same. The try catch as coded basically is an unhandled exception, which could have been raised without the try catch.

Here's one more that completely baffled me when I came upon it recently.

Try
IO.File.Move(oldPath, newPath)
Catch (ex As Exception)
IO.File.Move(oldPath, newPath)
End Try

Go Figure! What is this? "If at first you don't succeed, Try, Try again?"

Take a minute and comment with something really dumb that you have done or seen.

0 comments: