A LINQ Gotcha – First Operator

So, I was using the First operator to return the first item element in a sequence matching a predicate. I expected a null to be returned if the sequence did not contain any matching elements, but found (well, Scott found) that this actually throws an InvalidOperationException. Turns out I should have been using the FirstOrDefault operator instead…

14 December 2007

Edge Cases

Ten years of professional software development have given me a healthy awareness of edge cases – I’m always trying to code defensively, validate input, catch exceptions, use assertions, and of course pick holes in sloppy specifications (“ah, but what if…”). I must learn that these skills should not always be applied to my personal life though, as exemplified by a conversation with The Wife yesterday: _Jocelyn (excitedly): “We’re going to have a ‘Secret Santa’ for all the babies in our antenatal group!” Me: “Huh. How does that work then?” Jocelyn: “Well, we each buy a gift for under £10, put them into a bag, and each pick one.” Me: “What happens if you pick out the gift you bought?” Jocelyn (less excitedly): “Well, you put it back and pick another.” Me: “So, you have an even number of babies in the group?” Jocelyn (testily): “There are seven.” Me: “Then what happens if the last person picks their own gift?” Jocelyn (deflated): “Ian…! OK, so we won’t open any gifts until they’re all selected – happy now?” ...

10 December 2007

Benjamin George Nelson

It gives me unparalleled joy to announce the birth of Mr Benjamin George Nelson. Following a relatively swift labour, the new arrival entered the world suddenly at York Hospital on Wednesday at 22:24 local time (see this time in your time zone). Birth mass was 4.185 kilograms (9 pounds 3 ounces), length was 51 centimetres (20 inches).

27 July 2007

Paulo's Last Munro Photos

I’ve finally gotten round to processing and uploading photos from Paulo’s Last Munro weekend. The weather on Ben More was truly appalling, so the majority of the images were, unsurprisingly, taken within the cosy confines of the Craignure Inn, who gave us a wonderfully warm welcome.

4 July 2007

Software Architect 2007

Last week I had the pleasure of spending a few days in London attending the Software Architect 2007 conference at the Barbican centre. It was a good conference, providing me with some useful and interesting new ideas and food for thought, whilst confirming that our team at Marshalls are generally going about things in “the right way”, which is nice. Looking through my notes, the main themes that kept recurring within the different presentations that I attended were: ...

17 June 2007

A C# Postcode Struct with Parser

As discussed recently, I’ve been trying to knock together a class struct to represent a UK postcode, provide a means of parsing a string as potentially being a valid postcode (or optionally just an outer code), and split that postcode into “outer” and “inner” code. I say potentially because, as you’ll know if you’ve looked into this topic at all, it’s impossible to validate whether a string truly does represent a postcode without querying the (copyrighted and expensive-to-license) Postcode Address File. As a result, my solution is not very stringent – it is possible to persuade it to successfully parse an invalid postcode, but hopefully there should be no occasions when a valid postcode is rejected. ...

29 May 2007

Postcode Validation

Wikipedia cracks me up sometimes. I’m sat here at my desk, trying to knock together some C# code to quickly validate an entered string as being a UK postcode. Naturally I turned to this Wikipedia article for assistance, where I find this quip: “Automatic validation of postcodes on the basis of pattern feasibility is therefore almost impossible to design, and the system contains no self-validating feature such as a check digit. Completely accurate validation is only possible by attempting to deliver mail to the address, and verifying with the recipient.” ...

23 May 2007

SQL 2005 Unleashed

Many moons (and about four jobs) ago, a wise DBA by the name of David Hanson once recommended to me a book called Microsoft SQL Server 2000 Unleashed. I took his advice, bought a copy, and it rapidly became one of the most dog-eared and oft-thumbed computing books I have ever owned. It is comprehensive, deep, broad, well-written and covers everything one might ever wish to know about SQL Server 2000. With its help and guidance I came to love and respect Microsoft’s premier database product, passing the 70-229 exam by a comfortable margin. ...

18 May 2007

MSDN Technical Roadshow 2007

I’m off to the MSDN Technical roadshow in Harrogate tomorrow, and am actually really looking forward to it this time. These events are free, so always well worth attending when they’re local, but some years are certainly better than others – it mostly depends on the material being covered. I remember one year circa 2003-4, when .NET was well established, but before the Whidbey release, so the majority of the day was effectively just a sales pitch covering elementary .NET concepts, presumably for those laggards who hadn’t yet made the great leap from VB6. Another data-binding demo, anybody? Yawn. ...

12 March 2007

More Tufte Books

When I mentioned Edward R. Tufte’s excellent The Visual Display of Quantitative Information in a recent blog post, it prompted me to search North Yorkshire’s online library catalogue to see if they had any more of the great man’s works. I was delighted to find that both Envisioning Information and Visual Explanations were available, yet languishing in a storage room somewhere rather than being on the shelves of one of the county’s libraries! So, I placed a request and they turned up at my local branch a few days later. ...

28 February 2007

Spot The Misleading Graph

Fifty-three years since Darrell Huff published the seminal How to Lie with Statistics, and still we have newspapers as august as The Times pulling the oldest trick in the book: At first glance it all looks very impressive, but closer inspection of the comparison with sales of the Torygraph reveal a mere 8.7% sales lead, not more than double as suggested by the graphic.Not fooled. Another favourite book of mine that covers the still-relevant topic of graphical integrity is Edward Tufte’s The Visual Display of Quantitative Information. It’s one of those timeless works that I look forward to sharing with the next generation. ...

19 February 2007

Dangling Off A Skyscraper

I keep intending, and forgetting to post a couple of videos from our US holiday last April. I suppose I was hoping to get round to writing up my paper notes from the holiday, but it’s becoming apparent that won’t happen anytime soon, so let’s skip forward to the funny bits: We spent a couple of nights at the Stratosphere Hotel in Las Vegas, which is the tallest observation tower in the United States. Atop the tower are three “thrill rides”, and I foolishly tried all of them whilst Jocelyn videoed proceedings from a safe distance. ...

11 February 2007

Ian Nelson, MCSD.Net

I am now a Microsoft Certified Solution Developer in .NET 1.x technologies. This is a qualification that I’ve been working towards on and (more often than not) off for the past four years or so. It’s not really the case that the exams were super-hard, just that it took occasional motivation to get round to taking them! So, was it worth it? Did I learn anything en route? Did the exams boost my employability? Would I be more inclined to employ someone with an MCSD than an applicant without? ...

11 February 2007

For Our Tomorrows

On this Remembrance Sunday, permit me to share with you a photo that my cousin Helen took this week of our Granduncle’s grave in France. Private William Henry Worfolk (1896 – 1916) of the York and Lancaster Regiment was my Grandfather’s elder brother (by four years), and was only just old enough to fight (and die) in the First World War. A couple of years later and it could just as easily have been my grandfather, and then I wouldn’t be here to tell you this tale. Ninety years on from that most bloody of wars, we still have much to be thankful for. ...

12 November 2006

A Genealogical Milestone

Late last night I reached a small but significant milestone in my family tree research: I now know the names of my sixteen great-great-grandparents! Or so I believe – I just need to wait for a couple of certificates to arrive from the GRO to prove my theories. So, who do I think I am? Well, at this stage it appears that my blood is: 50.0% English 37.5% Scottish 12.5% Irish Those sixteen ancestors were born between 1829 and 1860. ...

6 November 2006