.NET

.NET

Generic Factory over Object Initializers

 

Consider the following generic factory method:     public class Builder     {         public static TType Create<TType>(Action<TType> actionOnTType) where TType : new()         {             var item = new TType();             actionOnTType(item);             return item;         }     }  which allows us to do something like this:             var aRunningCar = Builder.Create<Car>(car =>             {                 car.Engine = new Engine("v8");                 car.Start();             }); What are your thoughts on the above over the standard object initializers found in C# 3.0?  Initially the difference is that this allows us to invoke methods on the instance as...

Microsoft Mocking Framework and TypeMock

 

While everyone has been wondering over the past couple years when Microsoft would ship its own version of a mocking framework, as of yesterday TypeMock announced it has been acquired by Microsoft and the product will be included in future versions of Visual Studio.  At least they didn't follow their previous pattern and create a less powerful clone of other products already on the market.  Hmm, interesting this should be me thinks.  Next to follow, possibly a DynamicProxy2 clone from Microsoft?  What day is today again?

Creating Objects - Round 3

 

Ayende has been discussing the different ways of actually creating objects in .NET and the perf cost associated to each of them.  I thought I'd add to the mix one more method, using the DLR.  I've talked to several people who have identified concerns with the speed of the DLR so I found the results rather interesting.  The context is still the same, identify the time it takes to construct one million Created instances. The delegate:  delegate Created CreateInstance(int num, string name); The structure:    public class Created    {        public int Num;        public string Name;        public Created(int num,...

Vibrant Ink for Visual Studio 2008

 

For those of you that enjoy the Vibrant Ink theme that was originially produced for Textmate, John Lam converted it to work under both Vim and Visual Studio 2005 a while back.  I've enjoyed that for both editors, however with Visual Studio 2008 out, we need to update.  I've updated the settings file to now work with Visual Studio 2008.  Feel free to download it here.

Code to Live Video from Tulsa TechFest

 

Jeffrey Palermo and I sat down with Chris Koenig while at Tulsa TechFest back in October to chat about the new ASP.NET MVC stack.  Josh Holmes just published an extract of our conversation out on Channel 9 here.  This was recorded back in October, right after the ASP.NET MVC stack was first made public by Scott Guthrie down at the ALT.NET conference in Austin, TX.  We discussed other things such as the open source movement and it's relationship to the Java counterpart but they didn't make the cut in the editing room.  You can watch the video directly here.  Have...

The Pitfalls of Concession

 

Ayende recently posted about a design aspect of the new MVC framework coming down from Microsoft. Ayende raised concern about the design requirement of attributing your public actions on a controller. He points out that Rob Conery has a 6 page post covering the usage of a tool to mask the pain involved in typing the excess noise. A follow-up by Phil Haack presents a solution through subclassing that allows one to avoid the attribute. What about composition instead? The real reason behind this post is not to discuss the merit of a design decision directly, but...

Castle Presentation

 

I will be presenting at the September Iowa .NET User Group meeting, if you don't have any plans September 5th come on out for some free pizza and a presentation on the Castle MicroKernel/WindsorContainer. I will be giving an introduction to the dependency inversion principal, and then we will jump into MicroKernel and the extensions that have been built on top of MicroKernel to create WindsorContainer. My final demo will include a custom facility to extend WindsorContainer that will provide integration with the memcached distributed object caching system. I hope to see you out there!

DLR Scores

 

In the constant battle for staying ahead in the software world, Microsoft appears to have a slight edge from the dynamic language perspective. The DLR is being created to support the various dynamic languages that Microsoft intends on releasing, IronPython and recently IronRuby with a dynamic version of Visual Basic in the future (this reminds me of VBScript and the VARIANT data type - sigh). Microsoft hasn't exactly been on the forefront of dynamic languages, Smalltalk has been around for over 25 years. However what does appear to be changing is the way languages and platforms...

IronRuby Emerges

 

So John Lam annouced the alpha release of IronRuby, he mentions that they did a lot of work on string and arrays, unfortunately, with the current release .NET types aren't able to execute Ruby mixins. I was hoping to do something like the following: require 'mscorlib' require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' list = System::Collections::ArrayList.new list.Add(5) list.Add(10) list.Add(15) list.extend Enumerable list.each {|i| puts i.to_i} The following code does execute: require 'mscorlib' require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' require 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Application = System::Windows::Forms::Application Form = System::Windows::Forms::Form Button = System::Windows::Forms::Button Point = System::Drawing::Point Size = System::Drawing::Size MessageBox = System::Windows::Forms::MessageBox window = Form.new window.text = 'Testing IronRuby'...

EventWaitHandle.Set

 

This blog has been pretty quiet lately, what's going on, has Nick fallen asleep? Nope, I've just been busy wrapping a few things up. Most importantly, I got married on June 2nd, and we took a few weeks off to head down to Hawaii and relax. If you've never been, my recommendation is to skip Maui and head right for Kauai. I will be presenting at the Cedar Rapids User Group on January 7, giving my presentation on Castle's MicroKernel/Windsor Container, so if you are interesting in hearing more about the light-weight IoC container come on...