Yield Return Practical Use

In my previous post about the “yield return” syntax, I highlighted my displeasure with the fact that it doesn’t actually enumerate the yielded values until accessed. In my opinion, this is dangerous for developers who do not clearly understand it’s use. The issue is that at face value it appears to simply be a shortcut for returning a collection, avoiding the need to explicitly declare the collection object and add items....

January 22, 2009 · Joshua Marble

Visual Studio Fail

I’m not sure how you get this, but I got it. First time ever. Click ‘OK’ to drive a wooden stake through its head. “There are many ways to kill a zombie, but the most satisfying is stabbing them through the head with a wooden stake.” – Dwight Schrute

January 14, 2009 · Joshua Marble

Framework Design Guidelines

I’ve been thinking lately about general framework design. Over the next year, we’ll be redesigning the underlying framework of our product for just about every level. Given this undertaking and my strong desire to make sure it’s designed in the most flexible and extensible way, I’m looking for principles that we can apply to our code. I think “Framework Design Guidelines” by Krzysztof Cwalina and Brad Abrams is the resource I’m looking for....

December 23, 2008 · Joshua Marble

Piriform – Makers of CCleaner And Other Awesome Tools

I first heard of CCleaner from Scott Hanselman in his “The Developer’s Quitting Your Job Technology Checklist”. It since has been updated regularly and has many nice and useful features, all for free. CCleaner is developed by Piriform, a company dedicated to providing quality software for free. CCLeaner gets some pretty good press on tech blogs, but I don’t see a lot of mention of Piriform’s other awesome free software, Defraggler and Recuva....

December 17, 2008 · Joshua Marble

Improvements to Generic Sort Comparisons

I have written previously about my solution for providing sorting support to the DataGridView using a custom BindingList<T> and an implementation of my own ISortComparer<T> interface. In that solution, I had provided logic for trying to compare a few simple types generically using reflection. However, a coworker recently pointed out that trying to cast the property values to IComparable would allow for a more robust comparison that does not rely in switching the object’s type....

November 24, 2008 · Joshua Marble

Comparison and Casting Operators

Today, I’m writing about operators in .Net because I think they are a very powerful but underutilized feature of the framework. I’ve worked with comparison operators ( == !=) in the past, but never really implemented them in a production project. However, the are also casting operators, which allow you to provide implicit or explicit conversion functionality between custom types. Operators can be used to provide custom logic for comparison of objects....

November 11, 2008 · Joshua Marble

The Action Delegate

If you do any asynchronous work in Windows Forms, you’ve probably used the MethodInvoker delegate a fair amount to invoke a method asynchronously. It’s convenient to have a built-in framework delegate so you aren’t defining your own everywhere. But what about when you’re not in the System.Windows.Forms namespace? In the past, I had simply defined my own delegate with no parameters and used it. But why create your own simple delegate everywhere when you don’t need any parameters or other customizations on the delegate?...

November 6, 2008 · Joshua Marble

Where Is My New iGoogle

Several months ago I was (randomly) given the new iGoogle homepage before it was released. I liked the changes and got used to the new interface. However, a while back, around the time they released the new iGoogle design publicly, my iGoogle reverted to the old design. Now I know a lot of people are saying they don’t like the new design and have good arguments against it, but I liked the new design fine and it’s my nature to want to run the latest and greatest version....

October 31, 2008 · Joshua Marble

Yield Return Strange Behavior

I was working on generating some test data today and realize something about “yield return” that troubles me. It seems to call the iteration code multiple times. Examples are the easiest way to demonstrate this behavior, so check the console application below. static void Main(string[] args) { IEnumerable<string> guids = GetGuids(4); foreach (string guid in guids) Console.WriteLine(guid); foreach (string guid in guids) Console.WriteLine(guid); Console.ReadLine(); } static IEnumerable<string> GetGuids(int count) { for (int i = 0; i < count; i++) { yield return Guid....

October 29, 2008 · Joshua Marble

Force Delete Files or Folders In Windows

I was rearranging some music last week using a tag scanning program, but during the process I ended up with an empty folder with a funny name. I went to simply delete the folder, but Windows reported that it could not delete the folder because it was no longer available. First I tried using the command prompt to delete it, but that also failed. So, I naturally rebooted my machine to delete the folder on a fresh reboot....

October 27, 2008 · Joshua Marble