Nick Parker
My ramblings on .NET...

Microsoft Mocking Framework and TypeMock

Tuesday, 1 April 2008 04:11 by nickp
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?

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Creating Objects - Round 3

Wednesday, 5 March 2008 18:08 by nickp

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, string name)
        {
            Num = num;
            Name = name;
        }
    }

 Grab the constructor:

ConstructorInfo ci = typeof (Created).GetConstructors()[0];

Define the parameters to be passed to the constructor (relative to the code block we are about to define):

Variable num = Variable.Parameter(SymbolTable.StringToId("num"), typeof (int));
Variable name = Variable.Parameter(SymbolTable.StringToId("name"), typeof (string));

Build a code block with the Ast factories for building expressions (this builds our function for creating new Created instances with our parameters):

CodeBlock block = Ast.CodeBlock("CreateInstance", typeof (Created),
                                  Ast.Return(Ast.New(ci, new Expression[] {Ast.Read(num), Ast.Read(name)})),
                                  new Variable[] {num, name}, new Variable[0]);

Compile our block:

CreateInstance create_instance = TreeCompiler.CompileBlock<CreateInstance>(block); 

 Invoke the compiled instance:

int iterations = 1000000;
Stopwatch watch = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
{
     create_instance(i, i.ToString());
}

The results are rather impressive, the run time on my machine was 00:00:00.2737688.  It looks like creating objects within the DLR via a dynamic code block is pretty cheap.  I've included the source here if you want to run the example.  The DLR bits are based off a release from CodePlex two days ago, the RubyForge bits are much older and will not compile with the above code.  Thoughts?

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | DLR | Open Source | Ruby | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

Vibrant Ink for Visual Studio 2008

Sunday, 10 February 2008 10:35 by nickp

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.

Currently rated 4.8 by 4 people

  • Currently 4.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Code to Live Video from Tulsa TechFest

Tuesday, 5 February 2008 20:09 by nickp
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 you played with the new MVC stack yet, if so what do you think?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | Open Source | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

The Pitfalls of Concession

Sunday, 9 December 2007 17:45 by nickp
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 the more off-handed results that come from it. If Microsoft is protecting the developer from making mistakes by requiring an attribute here and there within a controller, well, why wouldn't they protect the developer all over the place? Where does one draw a line in the sand from a design perspective? If we made a concession before, can we use that as justification for yet another design decision that might change the direction of the software even further? While the CTP is baked, the API can still change and Microsoft is listening, pipe up if you care to share your opinion.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Castle Presentation

Saturday, 18 August 2007 14:09 by nickp

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!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Open Source | .NET | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

DLR Scores

Wednesday, 1 August 2007 01:16 by nickp

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 operate and target themselves. It's all about the VM anymore, period, and the services it can provide. The DLR is being built to provide these new and future languages with a core set of services that make targeting the CLR easier from a dynamic perspective. JRuby has been a work in progress for the past five years in which users can use Ruby to target the JVM. JRuby isn't the only dynamic language attempting to target the JVM, there's Jython and Groovy to name a few. Of course what comes from this is the same problem Java has been plagued with for years, there are hundreds of different solutions/frameworks/tools/libraries available for you to choose from for your project. In order to avoid this duplication of effort, a new project has been created called the JVM language runtime as a mechanism to avoid the duplicated efforts of the historical past. To that I say Microsoft is ahead of the game - touché.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

IronRuby Emerges

Monday, 23 July 2007 17:57 by nickp

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'
window.size = Size.new(250, 200)
button = Button.new
button.text = 'Click Me'
button.location = Point.new(75, 75)
button.click {|sender, e| MessageBox.show 'I was clicked'}
window.controls.add(button)
Application.EnableVisualStyles
Application.run(window)

Of all the windowing toolkits I've seen for Ruby, the .NET Framework is the easiest to read for me, although I'm sure toolkits like Swiby will get noticed, especially due to it's DSL syntax which is the new hotness in the development world these days. Next up, extending the IronRuby Builtins.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | Open Source | Ruby | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

EventWaitHandle.Set

Monday, 16 July 2007 22:18 by nickp

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 out. My presentation starts with an introduction to the IoC concepts and progresses through extending the container via custom facilities.

Last but not least, last year my boss Eric Jacobs got Levi Rosol and I involved in the Ankeny Summerfest cardboard boat regatta. Last year we didn't quiet make it too far past the starting line, however we took notes and gave it another attempt this past weekend. Results - Success, we made it down and back without sinking, a major step forward. Next year I plan to build a boat that will last longer than a single run, however we will do it in Eric's style by only beginning the construction two nights in advance. :-) My wife recorded the event, take a look:

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

ReSharper 3.0 Released

Thursday, 21 June 2007 17:28 by nickp
Absolutely amazing, do not pass go, do not collection $200, just go get it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | Software
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed