Welcome to Manicprogrammer Sign in | Join | Help

Want to feel good about your code???

Want to feel good about your code? I'm migrating some legacy .NET 1.1 code (that no one still with the organization wrote) into the latest framework and keep running into method after method that looks like the below.  Hmm... If OK then do this. Else just do the same thing.

   1: If Result = SQLResults.OK Then
   2:      pnlonjobs.Visible = True
   3:      dlstOnJobs.DataSource = dtSearchTable
   4:      dlstOnJobs.DataBind()
   5:  Else
   6:      pnlonjobs.Visible = True
   7:      dlstOnJobs.DataSource = dtSearchTable
   8:      dlstOnJobs.DataBind()
   9: End If

 

I have dealt with a lot of legacy application and long lived software and they always get into embarrassing states but for the life of me I can't imagine the mechanism behind code ever evolving into this outside of some sort of global search and replace. Mind boggling.

 

And about as good as the above. That code lived in the try block below... again in method after method after method this was the pattern.

   1: Try
   2:     ...
   3: Catch ex As Exception
   4:     Throw ex
   5: Finally
   6:     ...
   7: End Try

 

There is an arguable case for the above if you wish to blow away the underlying stack trace from the exception before it bubbles up... but this is not the case here I assure you.

Published Saturday, June 28, 2008 12:10 PM by michaelruminer

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Enter the text you see in the image:

Leave a Comment

(required) 
required 
(required)