A Request

If anybody is writing .Net code that in the future I am going to have to find an error in, can they refrain from doing things like this:

try
{
...
}
catch (Exception e)
{
throw new ApplicationException("ConnectionException has occured: " + e.Message);
}
finally
{
....
}

The particular application I was working on this morning used this particular gem pretty well everywhere. The problem was that we were getting an unhandled ApplicationException – the re-thrown error wasn’t being trapped anywhere else – and since the above bit of code throws away the stack trace from the original exception, we were left trying to guess where the error was actually occurring.

The irony is that the code was written by a contractor who apparently had a pretty stellar CV, and amongst other things quite regularly criticised other people on the team over their apparent bad programming. His contract wasn’t renewed, and since then we’ve been discovering quite how bad his programming really is – a definite lesson that however good a contractor appears on paper, you need to properly monitor what they are doing.

Other gems in this particular application include every SQL statement being built by concatenating strings together – and no, not a StringBuilder in sight. Using ToString() to do the conversions where needed, including quite a few points where he calls ToString() on a string – indeed a large amount of the data is just held as strings anyway, only being converted back to integers or dates in the stored procedures when SQLServer needs the right types. He had also written his own replace function, which he was using instead of String.Replace although it was functionally identical, and that wasn’t the only place he’d hand crafted code that replicated functionality in the framework. The code was littered with other common errors, for example it’s a good job we don’t have anybody with the surname O’Reilly…

Since we were fixing a specific problem, much as I would like to, there wasn’t the opportunity to fix all of these other problems, essentially we have to wait until something else breaks, and fix it then. And the source of the problem today? A stored procedure that was trying to convert one of the multitude of strings being passed through back to an integer in order to use it. That conversion was failing and throwing an error that was passed back to the client and helpfully chucked away by the error handling code I started with – the only clue we had as to where it was going wrong was that the error message seemed like it was coming from SQLServer.

Never Upset a Lawyer

Years ago, a friend of mine was called as a witness for the prosecution in a local magistrates court. Although the charges were relatively minor, the defendant was the son of the agent of a rather senior politician of the time. The evidence against the defendant was pretty conclusive, however he chose to plead not guilty – more than that, rather than be defended by a solicitor, he instead turned up with a barrister who seemed to have been hired in an attempt to try and get the young gentleman off the hook. The barrister then proceeded to pick through all of the evidence dragging the whole proceedings out, whilst at the same time giving out such an attitude of disrespect that by the end of it all, the magistrate was visibly annoyed at the whole farrago. As a result, the magistrate then handed down a sentence rather above what would have been given had the defendant just pleaded guilty.

Along similar lines, we have another example of why you shouldn’t upset a lawyer – especially if you’re another lawyer – with the latest instalment of the Mark Brewer SPCK SSG story. One of numerous actions that got people annoyed was the fact that Brewer attempted to have SSG, a UK based charity, declared bankrupt in the USA, naming a non-existent US company as the entity being wound up – the belief being that it was being done to hide from the mainly UK creditors (it is worth mentioning that Brewer maintains that it is being done in the USA for other reasons). Needless to say, the court in the USA chucked out the case as being “in bad faith” – meaning that it was filed for a wrong or improper purpose – but not before a whole load of work had had to have been done. The non-existent company wasn’t the only odd thing about it though, among another of other aspects of the case that smelt fishy were the fact that Brewer’s own firm of lawyers were the ones acting for the non-existent company that he was trying to have declared bankrupt – so Brewer was both one of the people named as being part of the non-existent company, and also the lawyer acting in the case – and there was also another Brewer company called the ENC Shop Management Company that wasn’t even mentioned in the motion.

Now comes news that the person who had to do a lot of that work, trustee for the case Randy Williams has hit back filing a motion for sanctions against Brewer. Matt Wardman has a great review of the motion, but some of the gems it contains are worth highlighting:

  • Requests that Randy Williams expenses in dealing with the case be claimed back from Brewer.
  • Accuses Brewer of incomplete disclosure, including using one of Dave Walker’s posts to highlight the ENC Shop Management Company that wasn’t mentioned in proceedings.
  • Accuses Brewer of perpetrating a fraud on the court:

    “Mr. Brewer and his firm engaged in a concerted scheme to mislead this Court and to file a bad faith bankruptcy case. Mr. Brewer’s action in failing to disclose the true name of the Debtor and the cancellation of its contract and assignment of those rights to another closely held company of Mr. Brewer is a fraud on this Court. “Fraud on the court� is an intentional act by an officer of the Court to deflect the Court from knowing all of the facts necessary to make an appropriate judicial decision on the matter before it.�

  • Suggests that Brewer needs “20 hours of continuing legal education in the area of legal ethics”.
  • States that “the filing of this case in the United States where almost every creditor is located in the United Kingdom brings disrepute to the Bankruptcy Courts of the United States as they are being used as a haven for a party attempting to escape justice”.
  • That Brewer “seeks to use the designation of St. Stephen as a charity to somehow suggest that his conduct does not bear scrutiny”, before pointing out that the opposite should be true.
  • Concludes that “creditors, especially those in a situation like this who are looking at the system from outside U.S. borders, can see that parties who would attempt to subvert the law to escape their responsibilities will be punished”.

The whole impression of the document is that Randy Williams is really rather cheesed off. But putting that aside, the motion provides a lot that can be used back in the UK, and does seem to represent another spectacular backfire on Brewer’s part. Rather than quietly winding up the charity, the US court is now looking to punish him and his firm for bringing the motion in the first place.

Update: Brewer has issued a response to the request for sanctions, which Matt Wardman has reproduced largely admitting to the accusations and accepting the majority of the charges made against him. Another thing to note from Matt’s posting is that there is enough about Brewer on the internet now that even searching for his company name brings up a posting about him misleading the court as one of the first links. As I said, another spectacular backfire – the original postings by Dave Walker never had this sort of page rank on Google…

How I Got Started in Software Development

Craig tagged me for this ages ago, so I guess I’d probably best put in my answers!

How old were you when you started programming?
I think I probably started aged around ten or eleven, with the arrival of a Sinclair Spectrum at home and a BBC Model B at school.

How did you get started in programming?
I’m not really sure of this one, but I guess it was just the interest in how the respective computers worked, and the challenge of getting them to do things.

What was your first language?
Definitely Spectrum Basic. Until I was actually doing a proper Computer Science course at school – something that seems to have fallen by the wayside for generic ICT classes now – most of the software development was at home, thanks in part to the listings that the computer magazines produced. Indeed back then there was even an entire magazine devoted to listings, Sincliar Programs, which I used to read and copy in the listings from.

What was the first real program that you wrote?
I’m not really sure, probably the old classic “Hello World” in Spectrum Basic. In terms of a real serious project, that was probably the programming project for my A-Level in Computer Science.

What languages have you used since you started programming?
Basic – Spectrum/BBC/VB6/VB.Net, C, C++, Modula-2, 68000 assembler, Pop-11, Occam, COBOL, SQLWindows, Java, C#.

What Was Your First Programming Gig?
This was a summer job as a result of a work experience week, working for the British Holstein Friesian Cattle Society in Rickmansworth. Their business was keeping pedigree records for several different breeds of cattle and sheep, and on request producing the lineage of an animal, usually when the animal was being bought or sold. I spent the summer there during a key period from the point of view of their computers as they were moving from an old system written in COBOL running on an ageing ICL ME-29, over to a system written in C on a UNIX box. The COBOL was probably the experience that left the biggest impression, as in COBOL the indentation of the lines of code is important, and the editor only went forwards through the file, and only allowed you to edit the line at the bottom of the screen!

If you knew then what you know now, would you have started programming?
Definitely yes, not least because if I hadn’t have gone into programming professionally I would have probably become one of the worryingly large group of amateur programmers I’ve come across hacking together key business applications, all of whom would much rather be doing a programming job than the one they ended up in.

If there is one thing you learned along the way that you would tell new developers what would that be?
One of the main tips I’d give is to give yourself a broad and general base – having done a couple of crash courses in VB doesn’t make you a programmer. Most of the best ones I’ve come across over the years have been flexible and adaptable, and usuall spent several years doing a broad based course – generally a degree of some sort – where they have been given the broad basis that allows them to cross-train quickly as technologies change. They’ve also got the broad IT knowledge to understand what else is going on around their job – you might not ever program professionally in assembly, or do any deep level AI research, but it is surprising how much of that sort of stuff is useful in ‘normal’ programming. Don’t get me wrong, I’ve met quite a few people who have learnt programming on-the-job and can cope, but equally I’ve met a lot of others who aren’t adaptable and end up stuck. For example one contractor we’ve had at work is self-taught and writes great ASP code – unfortunately he was hired to write ASP.Net, and he really doesn’t get the differences. With our entire suite of software being rewritten in a multi-tier C# design, using an object-oriented design – because he’d been taught how to write ASP pages in VB, rather than being taught software engineering he was effectively unable to do what we needed.

Along those lines, I’d also advise anybody to keep your skills current, and be especially wary of companies that don’t keep up to date, or program in something that isn’t mainstream. The biggest problem to get into is ending up in a very small niche programming market as I did with SQLWindows. Luckily I found a new employer who was happy to cross-train me into VB. You’re never going to totally escape from maintaining the creaky old VB6 systems, but make sure you’re in a company where you get a balance.

What’s the most fun you’ve ever had… programming?
I’ve had times when I’ve enjoyed programming professionally, but still one of the most fun bits of programming I’ve had was on the LPMud we had running at university. The game was all running in a variation of C, and one you reached wizard level you got to add to the game by writing code – indeed the wizards got programming level access to the guts of the game so you could actually manipulate the game environment on the fly. Programming for that there wasn’t really any pressure, and in terms of the game there weren’t really any limitations on what you could produce. Professional programming, the majority of the time you are working to a spec, and for a customer, and you don’t get nearly so much freedom in what you do.

Catch Up

Okay, another bit of a gap in blogging, and another catch up!

Pregnancy wise, Beth has been back and forth to the hospital several times over the past couple of weeks with stuff related to the gestational diabetes. The dietary stuff didn’t overly work – indeed her blood sugar seems to go all over the place whatever she has actually been eating, as a result the hospital have given her insulin which she uses to bring her blood sugar back to acceptable levels. However as a diabetic, albeit a temporary one, we have had to notify both the DVLA, and the insurance companies for the cars. For the moment it is just a note on the policies – whether there is any change in premium is dependant on whether Beth’s blood sugar settles down again after the birth.

One thing I didn’t comment on last week was the final of Last Choir Standing. Unlike some of the shows of this ilk that we’ve watched, we actually had some idea what was happening being members of the choir. Pretty well from the start of the final stages, I’d been pretty sure the final two choirs would be ACM Gospel Choir, based our of the Academy of Contemporary Music in Guildford, and Only Men Aloud, a modern twist on the traditional male voice choir from Cardiff. However things were thrown somewhat into disarray by the shock exit of ACM in the semi-final. Now I don’t know quite whether the guys from ACM got over confident and were caught out by the other choirs improving more, or whether they just had a bad night, but it did seem to thrown the competition open a bit. However by the end, despite some stunning performances – the improvement in Ysgol Glanaethwy, the youth choir from Bangor was amazing, and I’m still very impressed that a youth choir would attempt and produce such a fantastic performance of O Fortuna – but the ultimate winners were a well deserved Only Men Aloud. If you want to hear what some of the music was like, ACM Gospel Choir have an album newly released – although listening to it I can certainly hear the voices of some of the judges as a couple of things they spotted are present on the album.

Reality TV wise we’ve also had the finale of this years Big Brother. What perhaps is most interesting about this is that it was a bit of a bad night for the bookies as there was no clear winner. If you compare the final percentages for the 2008 finale with the results in 2007 you can see that each evictee on the final night was within a few percentage points of staying it – and the final winner was decided on only about three percent of the vote compared to a lead of over twenty percent last year – really it could have gone to almost any of the final five. Quite what will happen next year I don’t know – the programme got lower ratings than ever this year, and the show isn’t the guarantee of even Z-list status it once was. As this Times article from today quotes Craig Phillips winner of the first series:

“I speak to a lot of Big Brother contestants from the past few years and they’re all struggling. They can’t get work in the media but they can’t get a ‘normal’ job in a supermarket. It’s not going to be all red carpets for this year’s winner.”

I doubt they’ll drop the show before it’s tenth anniversary next year, but quite what it’s longevity will be after that I don’t know.