The Artima Developer Community
Sponsored Link

.NET Buzz Forum
What's wrong with this code #4 - discussion...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
What's wrong with this code #4 - discussion... Posted: Dec 8, 2004 10:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: What's wrong with this code #4 - discussion...
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

I've decided to use "discussion" rather than "answer" on these.

So, in reference to the last question:

First, thanks to all who posted. The discussions in the comments are always interesting to read, and I usually learn something from them.

I was going for the call to GC.Collect(). The intention of the user was to clean up the NetworkResponse objects that came back from the call to GetNetwork().

This is almost always the wrong thing to do. Rico does a far better job discussing it here than I could.

So, that's what I was going for, but it looks like I'll need to take a bit more care in creating my examples, to limit the possibilities a bit.

To expand a bit on some of the comments:

There was a fair amount of discussion about resource leaks. Given what I wrote, there probably isn't enough information to determine whether a resource leak is an issue.

There was also a lot about data validation. Data validation is important when you're writing API routines and/or if you have security concerns, but my personal choice would be not to add data validation to this routine, because the runtime does a pretty good job in most cases. If, for example, the ArrayList is null, then the foreach loop is going to throw an exception without me checking.

The disadvantage of that approach is that the exception may not be quite as informative as a hand-coded one.

Hope that makes sense. 

 

Read: What's wrong with this code #4 - discussion...

Topic: HDTV Basics Previous Topic   Next Topic Topic: Non-Admin Development in VS.NET 2003

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use