Wrap Any Class in Dynamic Goodness

08/11/2011 1 comment

I use the decorator pattern like it’s going out of style. Not really. I would, though, if it didn’t tend to lead to class explosion. Instead of using it in a broad way, I tend to reach for it in a couple of common scenarios:

  1. when someone else’s object doesn’t do what I want it to, and isn’t open for extension, or
  2. when I want to pass an object to a method that wouldn’t accept the object otherwise.

However, decoration can be tedious, can violate the DRY principle, and can lead to lots of little wrapper classes lying around that just clutter a project up. What if we can prevent that? Read more…

Towards Better Graph Loading Via Conditional Types

07/13/2011 Leave a comment

One of my pet peeves is the cruft we often add to our objects to support graph loading. For example, we might create a special “lazy loading” type wrapper (e.g. Lazy) or we might create two independent fields that represent, in effect, the same thing (e.g. Employee MyManager and Guid MyManager_ID). Neither is clean, and each has its issues. I want something better. Read more…

A Handy MSDN Bookmarklet

04/12/2011 Leave a comment

If you’re like me, you don’t do all of your coding in Visual Studio.  That’s when you start to miss the convenience of just hitting F1 to bring up the MSDN documentation for a specific class.

To bring that simplicity to your browser, just paste the following into the URL field of a manually created bookmark:

javascript:(function(){c=prompt("Enter the fully-qualified name of a class, method, property, etc.:","System.Object");window.location="http://msdn.microsoft.com/en-us/library/"+c+"(v=VS.100).aspx"}());

Defaulting on Orchard CMS

04/04/2011 8 comments

When creating a new Orchard module, I needed to set the default value for an integer. The thing is, you can’t do it in your model class like you would normally do. Property getter/setters are just getting/setting the underlying record, and the constructor runs before the record object has been created. What now?

Read more…

Dangerous .NET CLR Quirk Lurks In Unfiltered Generic Methods

03/02/2011 3 comments

Step right up! Step right up! Come inside and watch in horror as our sample C# code compiles, runs, and spectacularly fails right before your unbelieving eyes.

Read more…