Posted on January 31st, 2010

See if you can spot the problem with the following C# code:


var list = new List { "fish", "and", "chips" };
for (int i = 0; i < list.Count; i++)
{
  list.Add(list[i].ToUpper());
}

As the title points out, this will cause an infinite loop, and will eat up all of your memory. What happens is that we iterate through the list once (i=0; list.Count = 3) and then add an element to the list. So the next loop we have (i=1; list.Count = 4). This is because anything in the parenthesis of the for operator will be evaluated every loop.

There are three options:

  1. Don't modify the list you are working on
  2. Save off list.Count to a variable and use that variable in the loop
  3. Use generics and/or Linq instead of manually walking the list yourself.

And the code was a dummy example code, nothing in use in any real system.

No Comments


Posted on January 15th, 2010

February is a busy month for me with several presentations and events going on:

  • On February 2nd I’ll be presenting to the Ft. Lauderdale .NET User’s Group on Data Dude (also known as Visual Studio Team Edition for Database Professionals). We’ll be covering how to do Test-First Development of your data and schemas. Information and Registration
  • On February 11th, I’ll be presenting Debugging Production .NET Applications to the Pasco County .NET User’s Group. This will cover the basics of memory management, CLR and using WinDBG and SOS to uncover what is *really* going on with your application. More information and registration
  • Then, on February 15th-17th I’m doing a class entitled Essential Skills for the Agile Developer (.NET Edition) in Tampa. This is a hands-on class covering mocking, TDD, Design Patterns and many other aspects to help you produce faster, higher-quality software
  • Finally, I’ll be speaking at the South Florida Code Camp on February 27th down in Ft. Lauderdale

Hope to see you at one or more of the events!

No Comments


Posted on January 6th, 2010

Earlier this year I gave two talks on Selling Software Craftsmanship in the Enterprise – one at the Software Craftsmanship North America conference, and one at Tampa BarCamp. The video from my presentation at Tampa BarCamp is now available. Enjoy!

Selling Software Craftsmanship in the Enterprise from Cory Foy on Vimeo.

, ,

No Comments


Posted on January 5th, 2010

Every year, Microsoft holds a conference called MIX for web developers and designers. This year they had an open call for sessions, and I was lucky enough to be able to submit four sessions. But I need your help – only the top 10 vote-getting sessions get in to MIX, and the voting ends January 15th. So take a few minutes and head over to http://visitmix.com/opencallvote and vote for your favorite sessions. Be sure to check out the sessions by Kevin Wolf, Justin Etheredge, Jim Zimmerman and Christopher Bennage as well. Thanks!

Go Vote Now!

No Comments