Archive for June, 2008

Stuff I’ve learned building MVC apps part 2

June 17th, 2008

If you want to embed images, you can use the Url helper to get a qualified path. e.g.:

<img alt="alt" src="<%= Url.Content("Content/Images/image.gif") %>" >

Stuff I’ve learned building MVC apps part 1

June 17th, 2008

If you’re using embedded code in an View or Master Page, you can use this declaration to avoid fully qualifying type names:

<%@ Import Namespace=”” %>


Unit Testing MVC Applications with Third Party Libraries

June 12th, 2008

When the MS Unit Testing framework runs, it copies any third party libraries you’ve referenced into the testing bin directory. If those libraries aren’t trusted, you’ll get a ‘Test run deployment issue xxx is not trusted” error.
The easiest way to solve this is to go the appropriate directory in Windows Explorer, got to Properties -> General and click on ‘unblock’.


Agile Ten Pin Bowling

June 11th, 2008

I’ve been delivering some Agile training recently, and for some of the exercises we’ve been using coding kata challenges. My favourite by a long way is proving to be ten-pin bowling scoring. It’s a very straight-forward algorithm, and yet it seems to take an awfully long time before everybody gets it – even those who actually go bowling. That makes it an excellent example of how test-first development can help to drive understanding requirements.
I set the task as implementing the following interface:

public interface IScorer
void Roll(int pinsDown);
int ScoreGame();

The exercise is being done in the context of test-first development, so most people start with a gutter game test case, then a game with no strikes or spares and so their Roll method tends to just add pinsDown to a running total. It’s when the test cases bring in strikes and spares that it all gets fun.
So far I’ve identified two thresholds: the point at which people abandon trying to keep state and score in the Roll method and refactor to storing the entire game history and scoring in ScoreGame instead (scoring by look ahead is much, much easier than doing it as you go for my money). There’s also a split between those who start to use objects, and those who stay with simple types.
As for me, well I’ll continue trying different approaches each time I look at the problem…