Damian Mehers' Blog Android, VR and Wearables from Geneva, Switzerland.

20Feb/092

Screencast: Testing, Mocking and Dependency Injection: more than just buzz-words

This 40 minute screencast covers unit testing, mocking, dependency injection, and inversion of control.

The idea is again that this will be is very much a hands-on, practical screencast.  Not technology for its own sake, but reviewing how and why these concepts evolved, and how they can be used in practice.

I'm not a TDD (Test Driven Development) fanatic, I don't think we should always have 100% code coverage with our tests, but I do think there is a lot of value in testing, and in making our code testable.

The screencast is available here http://damianblog.com/TestingMockingAndDependencyInjection.wmv

Filed under: Screencast 2 Comments
16Feb/091

Screencast intro to VS 2008 & .NET 3.5

I recently gave a presentation at work introducing some of the new features of VS 2008 and .NET 3.5.  No slides, just code.  And no pre-prepared chunks of code that are pasted into the editor either - everything written by hand.

In this 40 minute screencast I blast through Automatic Properties, Collection Initializers (Lists & Dictionaries), Implicit Typing, Anonymous Types, Extensions Methods, "Normal" Delegates, Anonymous Delegates, a natural evolution of delegates to Lambda expressions, Linq to objects using method chaining, Linq to objects using the natural Linq syntax, and finally Linq to XML.

Download or watch the screencast here: http://damianblog.com/WhatsNewInVS2008and.NET3.5.wmv

Filed under: Screencast 1 Comment
14Feb/091

Microsoft fixed my bug

Like a lot of people, when I first began developing on a "proper" Operating System (as opposed to the 8 bit computers I started with), sooner or later I convinced myself I'd found a bug in the operating system.

Of course I'd be wrong, and after suffering the embarrassment of discovering that it was my own stupidity, rather than an OS bug, that was causing the errors, I eventually acquired an automatic reflex to never ever believe that there was a bug in the OS.  It had to be a bug in my code.  This was a good thing, since I was always right.

Despite this, it seems that I never fully learned this lesson.  And so it was that last May I opened a bug report on Microsoft Connect, fully expecting to be gently, but firmly rebuffed, with an explanation of where exactly I'd gone wrong.

The issue that I was facing was in detecting whether a connection to my web application was coming from the local machine (running the web application), or from a remote machine.  I was calling the HttpListenerContext.Request.IsLocal method, and it was always returning false, even though the client was definitely local.

A little digging with Reflector showed that the method was implemented using "==" to compare the local address with the remote address, instead of the Equals method.  If the "==" operator had been overloaded then it would have worked.

A couple of days ago, I got a message saying that this was indeed a bug, and that it was fixed in version 4.0 of the .NET framework.  So it looks like I have finally actually discovered an honest-to-goodness bug.

Or perhaps they are just being kind to me.

Filed under: Debugging 1 Comment