December 2009 Blog Posts

Boy scouts on amphetamines

Disclaimer: No boy scouts were harmed in the production of this post The Boy Scout Rule is in my opinion a highly valuable mechanism for ensuring that a code base remains effective over time. The Boy Scouts of America have the rule “Leave the campground cleaner than you found it.”* Applying this to the code as it is maintained provides an efficient mechanism for ensuring code quality. The marginal effort required is relatively low as you are already working with it and hence the effort to understand the purpose and structure of the code is...

posted @ Sunday, December 27, 2009 2:03 PM | Feedback (0)

Just because I copied it doesn’t mean I’m going to leave it as is

I’ve recently had the need to link WCF and StructureMap (I don’t do “no IoC”). Jimmy Bogard has a nifty blog post with the requisite code to get this all working. The key class looks like this: public class StructureMapServiceBehavior : IServiceBehavior { public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) { ChannelDispatcher cd = cdb as ChannelDispatcher; ...

posted @ Monday, December 21, 2009 9:43 PM | Feedback (0)

NHibernate wierdness

I’ve got two separate projects at the moment that are both using query objects with NHibernate. The primary difference between the code is in the result transformer. One is using AliasToBeanResultsTransformer and the other AliasToBeanConstructorResultsTransformer. I had a problem with the former where the result object was not having any of its properties populated, which I determined to be because the projections were not having the alias defined (second optional property to the Add method). I just wrote a test for a query object in the project using AliasToBeanConstructorResultsTransformer to expose this problem so I could fix it (being a...

posted @ Friday, December 18, 2009 11:23 PM | Feedback (0)

I have more test code than solution code, and that’s OK

Looking at a personal project I’m doing at the moment I see that in terms of lines of code some of my test projects are significantly larger (up to 2.5 times in this system) than the projects they are testing. This seems like a large amount of overhead but a less superficial analysis shows that this really isn’t a negative. Looking at the code itself it becomes apparent that the test code is significantly more straightforward that the code it tests. My test code contains no conditional statements and will have only a single path of execution. Each test...

posted @ Friday, December 18, 2009 11:04 PM | Feedback (0)

Just how sneaky are blog spammers?

One of my recent posts attracted a comment that I can only interpret as attempt at stealth spam. The text of the comment was sufficiently vague that it could be considered on topic (if not well reasoned or insightful). What indicated the comment was spam instead of badly argued partisan hackery was the comment subject and URL. A cursory glance through the comments may not have identified this. I can only assume this is an attempt to game search engines (although I doubt Google and friends consider my blog to be particularly influential). The element I find interesting is...

posted @ Wednesday, December 16, 2009 10:13 PM | Feedback (0)

What’s good in .NET?

Lest my previous post is interpreted as my not liking the .NET platform, here’s a collection of things that are great (and which you will have to prise from my cold dead fingers). Lambdas, Extension Methods and the Enumerable and Queryable classes. How did we ever live without them? ReSharper. Visual Studio is merely my ReSharper hosting environment. Please JetBrains, write a .NET IDE. TestDriven.NET. So much faster than anything else out there for running unit tests. Does one thing, does it amazingly well. Gallio and MbUnit....

posted @ Sunday, December 13, 2009 3:45 PM | Feedback (0)

In which I rant about how Microsoft views developers

Disclaimer: Microsoft is a large and heterogeneous company and these comments will not necessarily apply to all of the organisation. I’ve just read a blog post by a Microsoft Software Engineer that represents what I believe is the fundamental problem with how Microsoft views the developers who use their tools and APIs. Here are the two key quotes: “We sit around the table designing APIs, and for the most part unless we have time to actually think through the extensibility/usage scenarios and ensure they’re safe or at least make some sense,...

posted @ Sunday, December 13, 2009 2:53 PM | Feedback (2)

I want non-nullable reference types

C# 2.0 introduced Nullable which gives us the ability to have nullable value types. This is handy and makes a number of scenarios easier (particularly database interaction in my experience). It’s very much in the category “nice to have”, useful but in most cases not essential. What I want is the inverse, reference types that cannot be null. NullReferenceException is one of the least helpful exceptions you can expect to encounter. It carries very little information, generally leaving you with “something broke in there somewhere and its all your fault”. In almost all cases you get this exception because...

posted @ Tuesday, December 08, 2009 9:31 PM | Feedback (2)