The myth that TDD or test-first slows you down is true

I'm sad to say it, but it is true. It slows you down. But not everytime, and not for everything. So let's be more specific on the cases where it DOES slow you down noticeably:

  • Cowboy or Duct Tape Programming Mode: If you code all day like crazy in a "cowboy" or "duct tape" programming mode, then it WILL slow you down, significantly. In this mode, you're hacking together stuff that works by pure luck, you're only superficially and typically manually "testing" the thing, before calling it "done" and move on. Someone will come after some day when the customer complains about a bug, and figure out what to do. Not your problem though, for sure. For all you care about, you might even have another job by then. Your productivity kicks ass, you're the fastest guy in the team, and can get "complete" features to your boss in record time. Everyone (who hasn't worked with you long enough) thinks you're a genious, 'cause you can get something that works on the first shot. Brilliant!...

Read full article

Writing meaningful, self-documenting, behavior-oriented tests

Over the years I've come to realize that the one-fixture-per-class approach to unit testing just doesn't scale. As the amount of variations in state and interactions increases, that file starts becoming a big soup of "Should" methods that are increasingly difficult to traverse and find later on. Essentially, since every test is doing the first "A" in AAA (Arrange-Act-Assert) too, that means the context is also part of the test method.

You can only make a method so long and remain understandable at a glance: IfRepositoryContainsACustomerAndAddingANewOneWithSameIdButDifferentAliasThenThrowsInvalidArgumentException. So, a while ago at Clarius we started exploring some of the concepts behind BDD (Behavior Driven Development), Context/Specification, etc., while working on an internal project. ...

Read full article

Are you smart enough to do without TDD

Ayende wrote a controversial post titled I'm so smart I don't need TDD Even tests has got to justify themselves ;-). It's important to read it, because it reinforces many of the reasons why "regular developers" (i.e. NOT *you* if you're even reading blogs as you are) continue to see "us" as some kind of unreachable and infallible elite of "hero programmers" who will eventually show up (i.e. be hired for big bucks, which we surely do want :)) and save the day....

Read full article

How to always open the vsixmanifest in XML view

The new VSIX projects contain a manifest that is by default opened with a designer. No matter how many times you specify that you want to open it with the XML editor by default, VS will continue to open it with the designer.

The only way to force the change is to manually modify the .csproj as follows:

<ItemGroup>
  <None Include="source.extension.vsixmanifest">
    <SubType>DesignerCode</SubType>
  </None>
</ItemGroup>

(on Beta1, the manifest file name would be just extension.vsixmanifest)

Read full article

Linq to Mocks is finally born

Last time I announced Linq to Mocks, some said Moq didn't actually have anything to do with Linq. Despite the heavy usage of lambda expressions and expression trees, the "q" in Linq is for "query" after all. And they were right, of course, but it was fun anyway, and the name is definitely cool IMO :).

But this time around, I'm happy to say that it's finally true. What the next version of Moq (early beta readily available now) allows you to express in a very declarative way essentially is:

from the universe of mocks, get me those that behave like this

Rather than procedurally defining how the mock will behave, its specification is part of the query:

ControllerContext controllerContext =
    (from context in Mocks.Query&lt;ControllerContext&gt;()
     where context.HttpContext.User.Identity.Name == "kzu" &amp;&amp;
           context.HttpContext.Request.IsAuthenticated == true &amp;&amp; 
           context.HttpContext.Request.Url == new Uri("http://moq.me") &amp;&amp;
           context.HttpContext.Response.ContentType == "application/xml"
     select context)
    .First();
...

Read full article

Improved type safety when dealing with generic types, generic methods and reflection

Compile-time safety is always important, as it reduces the chances that a refactoring can break existing code that compiles successfully. This benefit took me previously to the path of using expression trees to achieve strong-typed reflection.

There is, however, an alternative that works on previous versions of .NET and doesn’t involve expression trees. It essentially involves creating a delegate of the target method, and using the delegate properties to get to the corresponding MethodInfo:

Action&lt;string&gt; writeLine = Console.WriteLine;
MethodInfo writeLineMethod = writeLine.Method;

Note that the code above is very explicit about which overload of the WriteLine method to pick: the one with a single string argument and a void return value. You can leverage Action and Func various overloads to represent pretty much any method invocation. Also, if those do not fit, you can still create your own delegate type. The benefit, clearly, is that you now can refactor the defining class or method and the change will be picked automatically....

Read full article

Extensible Test Assertions With MSTest VSTS

If you have used more than one unit test framework (i.e. xUnit.NET, NUnit, MSTest/VSTS, etc.), chances are that you’ll miss features from one when using another.

In particular, MSTest/VSTS is lagging behind the crowd as it’s stuck in an NUnit circa 2002 (2.0) API for assertions and test attributes. This is what happens when you have a product that has to honor backwards compatibility even at the expense of usability and/or evolution of coding styles and API design.

Compare that with xUnit.NET, which had the luxury of starting from scratch just over a year ago, with all the accumulated learnings from NUnit and years of TDD work. The one assertion I missed the most from xUnit.NET was Throws:

Assert.Throws&lt;ArgumentNullException&gt;(() =&gt; service.Do(null));

Very explicit, highly precise check for an exception being thrown. MSTest, on the other hand, is still stuck in the (now even called a ...

Read full article

You Don’t Own Your Kindle Content: Amazon Does

Yes, what has been reported already is indeed very true.

I bought 1984 a while back (from another publisher, though). Hadn’t started it yet, but all of a sudden, it was gone yesterday. Got a refund email from Amazon for it, a refund I never asked (and I never asked to the return the item either).

Just two hours ago, though, I got an explanation from Amazon:

We have recently refunded your purchase of Nineteen Eighty-Four (1984) by George Orwell. This book was added to our catalog using our self-service platform by a third-party who did not have the rights to the books. When we were notified of this by the rights holder, we removed the illegal copies from our systems and refunded previous customers. We are working with the authorized rights holder to make this title available in our store very soon. We apologize for the inconvenience.

Amazon has made a couple not-too-smart choices lately. This one, and not allowing you to re-download your purchased DRM-free MP3 music.

I sincerely hope they fix both.

Read full article

Why Embedded Silverlight Makes Sense

So Microsoft just shipped Silverlight 3.0. Outstanding achievement in its own right for a company that takes multi-year cycles for pretty much every product, if you ask me.

Silverlight is indeed a very cool technology. With the latest additions and especially the HD media capabilities, it’s already ahead of the crowd that it started “emulating”. I want to see Silverlight further expanded in the following two scenarios:

  1. Replacement for Media Center XML language: who wants to learn yet another UI markup language? Deprecate it, move to Silverlight-only.
  2. Embedded chipset with built-in support for an “Silverlight Embedded” profile

Replacement for Media Center

Currently, Media Center uses its own markup language and lacks tooling support that Silverlight/WPF enjoy (Blend/VisualStudio). It’s time to let it die and embrace Silverlight markup, even if that requires creating a “Silverlight Media Center” profile with a subset that must be supported by extenders....

Read full article

How to get wi-fi network connectivity using Hyper-V

  1. Create a new Local Network with Virtual Network Manager (name it Hyper-V, for example)
  2. In the VHD, run msconfig.exe, in the Boot tab, click the Advanced options button, and select the Detect HAL option.
  3. Reboot the VM, reinstall the integration services and reboot again. Now you should get the new network adapter detected.
  4. Use ICS on the wi-fi network and select the local network Hyper-V as the one to share the connection with.
  5. To allow VPN access, you need to open a port (GRE) in the windows firewall as explained in http://help.wugnet.com/vista/VPN-server-configured-Generic-Routing-Encapsulatio-ftopict116489.html

Read full article

More Posts Next page »

Search

Go

This Blog

News

     

      Microsoft MVP Profile

Syndication