Bill Blogs in C#

Bill Wagner discusses C#, LINQ, and other items of interest

Eugenio Pace comments on IDisposable
Quote: "Why should a developer building "business solutions" ever care about closing a connection to a database, or even opening it?"

Eugenio has an interesting take on IDisposable, or the needs for business developers to actually care about resource acquisition or release.  He sez:

"The "using" statement is one step forward, but not enough in my opinion. In the same way you need to remember closing a connection, you need to remember using "using"."

Interesting stuff. I'm not sure the problem is as big as he makes it out though.  If you forget to close, or Dispose something, it's likely more of a performance error than a resource leak.  Eventually, the finalizer will clean up.  (Yes, I can construct code that makes it a fatal bug, but it's not often occurring in practice.)

It would be nice to create a class that had deterministic finalization, when needed though.



Eugenio's post
More on IDisposable.
Published Fri, Dec 24 2004 12:00 AM by wwagner
Filed under: ,