Nick Parker
My ramblings on .NET...

Vim Tip of the Day - File Explorer Navigation

Monday, 5 May 2008 21:17 by nickp

I don't know how I didn't come across this before, but when using the file explorer built into Vim, you can tell Vim to automatically switch the working directory to the current file you are editing.  Normally in Vim if you performed a ":cd c:\projects\blah" and subsequently navigated three folders deeper to edit a file (say “c:\projects\blah\foo\bar\foobar\fun.cs”), then choose to go back into the file explorer from your current location by issuing ":e .", the "c:\projects\blah" will be listed, not exactly where you might expect to be.  If you edit your _vimrc file and put the following command in when navigating the file explorer window, your current directory will automatically be set based on the file you are editing, and thus we would be dropped back into "c:\projects\blah\foo\bar\foobar").

autocmd BufEnter * lcd %:p:h 

Be the first to rate this post

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

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

Happy New Year

Tuesday, 1 January 2008 21:21 by nickp

Happy New Year everyone! I've been having some issues with my server recently, so if this post makes it out there all the better. I just received notification from Microsoft this morning that I have received my MVP award for 2008. I look forward to seeing everyone up in Seattle this coming April. I am planning on blogging more this year. We have been absurdly busy at work, but there are a lot of little nuggets I am looking forward to sharing. Until next time...

Currently rated 3.8 by 8 people

  • Currently 3.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   General
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | 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

ALT.NET Super Summary

Thursday, 11 October 2007 20:30 by nickp
It's simple in my opinion: Spreading pragmatic .NET

I wasn't there, however that's my interpretation of the vision. I think one of the core competencies any developer needs to espouse is passion. Passion is at the root of being a pragmatic developer, regardless of whether or not you’re doing .NET/Java/Ruby/LISP, etc. We are going through a hiring phase at work right now, during the interviews, passion is one of the top characteristics that I look for in a candidate. Passion is a catalyst for being pragmatic. Where does your passion lie?

 

Be the first to rate this post

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

NHibernate Performance

Saturday, 15 September 2007 12:17 by nickp

I am doing some research into the use of NHibernate over the use of the current data access layer we use at work. Overall, the results are very good compared with what we current had in place (lazy loading all properties, limited caching strategies to name a few), however I'm curious if anyone wants to ring in on past experience they have had with NHibernate. Our DBA is concerned that we will be losing out on cached execution plans from SQL Server by moving to NHibernate from stored procedures. It is my understanding that parameterize SQL can be just as fast, any comments?

Be the first to rate this post

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

Common Lisp

Thursday, 23 August 2007 10:28 by nickp
For those of you interested in functional languages (I know Jeremy is), APress has decided to give away it's PDF version of the book Practical Common Lisp for free. Go get it here.


UPDATE: The URL has been updated for the free book download.

Be the first to rate this post

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