Wednesday, March 21, 2012

A Day in the TDD Zone

What makes a great day of test driven development?
  1. A good plan.  This is going in my business layer, that is going in my data layer, and I'm not going to think about it just yet.  Let's wrap it in an interface and set it aside for a bit.
  2. Good tools.  NUnit of course, and a good mock suite.  Moq was rocking for me--built around lambda expressions, it makes dynamically created objects obey intellisense.  Pretty nifty.  And ReSharper is wonderful, letting you define methods and classes in your tests, and then Alt-Enter them into existence.  Control-U+Control-U to rerun your last test, and a nice 100% code coverage report for the class under test when your done.

Monday, March 19, 2012

Looking at LINQ

I've been digging through the discussion of LINQ in the Albahari brothers' C# 4.0 in a Nutshell: The Definitive Reference, and it has cleared up a number of points for me:
  1. At a compiler level, LINQ is a series of transformations done to expressions that begin with FROM and end with SELECT or GROUP BY.  These transformations turn free text queries into extension methods.  For example, var query = from A in aList select A.ToUpper() is transformed by the compiler into var query = aList.Select(a => a.ToUpper()). But, and this is a key point, the implementation of the methods is not determined.  You determine the implementation by the namespaces you include; you could write your own implementation of Select, Where, etc.