How do you return error conditions?

A recent poll on Code Project asked: How do you return error conditions?

I was disappointed to find that in the event of a “critical error that leaves the app in an undefined state” a shocking 5% of people would “cover up the mess and don’t say anything”. I think I would be shocked at even just one person responding with that answer. What is it with these people anyway? Do I have to explain why that is really unwise?

A greater percentage of people chose that answer in the event of non-critical errors, too. While the errors aren’t so bad, someone, somewhere will have to eventually clean up the mess.

It reminds me of a charting component that a company I used to work for bought. I evaluated various charting components and only one did absolutely every type of we wanted. However, in my report I did indicate that the component would not return any error status or throw an exeption when it failed so it was up to the developer who was using it to somehow work out if the component actually did what was asked of it. I just wonder how much more money was spent working around the problems the component created rather than benefit from it solving the existing problem.


NOTE: This post was rescued from the Google Cache. The original date was Monday, 23rd April, 2007

Google Map of Scottish Developers Event Location

Google maps has a cool feature that allows you to draw annotations on a map. I’ve created one detailing the transportation links (bus station, railway station and car parks) nearest the location of the upcoming Scottish Developer events.

To create a map like this all you need is an account with Google, then press the My Maps button on the Google Maps page.

NOTE: This blog entry was rescued from the Google Cache. It was originally dated Sunday, 29th April, 2007.

Unit Testing a Static Class

I’ve been trying to find a way to unit test a static class. That is, a class that has no instances. The problem has been that at the end of one test the class’s state could be altered which would mean that at the start of the next test its state would be unknown. This could lead to buggy unit tests.

The solution, I’ve found, is to invoke the type initialiser (sometimes known as the “class initialiser”, “static initialiser”, “static constructor” or “class constructor”) using reflection and ensure that all fields are set up there. That way, each unit test run will be starting the static class with a clean state and it no longer matters what the unit test does.

The code to invoke the type initialiser:

Type staticType = typeof(StaticClassName);
ConstructorInfo ci = staticType.TypeInitializer;
object[] parameters = new object[0];
ci.Invoke(null, parameters);


NOTE: This blog entry was rescued from the Google Cache. It was originally dated Monday 7th May, 2007.

There was one comment of note:

If you have a static class with state, then you have a singleton – generally to be avoided, but sometimes unavoidable. One way to think of singletons is as services – they provide a service to your app. Services usually interact with the outside world in some way, so for testing purposes it is useful to be able to switch between a real implementation and a Mock one.

So the trick that I use is to create a singleton service locator class, with a manual switch for changing from Test mode to Normal mode. Fowler calls this the Registry pattern in PoEAA.

5/8/2007 6:38 PM | Steve Campbell

Customised Google Search

I’ve been playing around with Google‘s customised search recently. It is great, I can create a filter on Google that means that, for the majority of the time, I get the results that I want. The majority of the time I search MSDN, Code Project, my own website and my blog.

  • MSDN is the main documentation for all of Microsoft‘s developer tools. It contains nearly everything I want to know.
  • Code Project fills in the gaps with examples of how to do certain things
  • My own website and blog are included because I often write things down so I don’t forget… Then I forget, so I have to find it again. It is much easier searching my own blog for something than it is to search the wide internet.

I’m sure I’ll be adding sites to the filter as I go along. The Microsoft DPEs’ blogs are likely to be added shortly as will a number of other blogs that I read regularly. All will be developer focused so if you want to use my custom search you can be assured that you won’t end up getting crazy results back about cute kittens.

Finally, if you want to use my custom search, just click this link:


NOTE: This blog entry was rescued from the Google Cache. It was originally dated Wednesday, 9th May, 2007.

Developer Day 5

DDD5 seems to have sold out in less that a week this time. I’ve also been looking at the final agenda to get an idea of what I’d like to see. There are a few time slots where I’d like to see two sessions at once so I’ll be thinking hard about which we go for.

For the moment my choice is as follows:

 An introduction to Unit Testing with Mock Objects (Presentation) Colin Angus Mackay

Mock objects are stand-in dummy objects that don’t have any functionality behind them, they just return the values to the application that the real object would have returned. Unit tests are supposed to test isolated bits of code. Mock objects ensure that if the code you are testing calls something external to the class being tested you don’t have to worry about what the actaul real class does. This talk expects the audience to be familiar with the concepts of Unit Testing and will introduce the concepts of Mock Objects.

Team Foundation Server – the answer to all project management problems? (Presentation) Richard Fennell

Sick of SourceSafe? Is Microsoft‘s Team Foundation Server the answer to all your problems? In this session I will cover the key components and usage of TFS, installation issues, the range of third party tools available and how to write your own tools using the API. The session will include demos of cool addins and tips drawn from bitter experience.

An Appraisal of “Object Thinking” (Presentation) Alan Dean

Have we got object-orientation all wrong? “Object Thinking” (ISBN 0-7356-1965-4) by David West asserts that we have. Alan Dean explores this assertion, and demonstrates self-describing objects / self-evaluating rules with code examples. More details…

Agile Methods for ISVs (Presentation) Gary Short

 We’ve all heard of agile methods but when they are spoken of it is mostly in the context of the enterprise. Being an ISV and being agile is a different kettle of fish. In this talk I’ll explain the differences between life as an ISV and life in the enterprise and then I’ll show you how to adapt agile methods for use in the ISV world.

Multithreading patterns (Presentation) Cristian Nicola

In the modern computers is more and more important to use multiple threads to benefit of the multi-core CPU readily available. This session explores multithreading patterns from the flows, data, resources and exceptions points of view, without actually being tied to a particular programming language.


NOTE: This entry was rescued from the Google Cache. The original was dated Sunday, 3rd June 2007.

Developer Day 5 Sold Out in 4 Days

Actually I don’t know how quickly Developer Day 5 sold out in. It was announced on May 30th and I noticed on June 2nd the registration page had a notice on it that any further registrations would be going directly onto the wait list. 350 (approx) developers signed up and packed out the venue in less than 4 days. That is simply amazing.

What is more interesting is that this event is taking place on a Saturday (out side office hours basically), so everyone attending is doing so in their own time. Developers are recognising that they need to keep their skills current.

I also know that there are quite a few people travelling, at their own expense, from Scotland. I’m sure there will be people traveling from the north of England also. So people are willing to put their hands in their pockets for somewhere in the region of £200+ expenses to go to this.

What gets me is that for the most part individual people are paying for this themselves. And for the most part it is their employer that is going to benefit. I wonder how many employers are actually helping their employees pay for this?


NOTE: This blog entry was rescued from the Google Cache. It was originally dated Sunday 3rd June, 2007.

Pay Pal, How I hate thee

Why is it that every time I try and use Pay Pal I get some sort of problem. I have recently “bought” a Microsoft Optical Trackball from a seller on eBay. Not something I do often, but it seems that eBay is the only place I can get these now – and since every other pointing device I use causes me pain after a few minutes of use I must resort to eBay.

When I won the auction I attempted to pay. I managed to log in to Pay Pal with out problems this time (see a previous rant about log in problems). But, since my credit card expired since the last time I used Pay Pal it naturally wanted new card details. So I provided them. It was the same credit card account as before, but with an updated expriry date. However Pay Pal refused to accept it saying the card was already on file. Since I arrived through the eBay “Pay Now” button the work flow did not allow me to go anywhere else. I must supply a different card or nothing. No option to choose an existing card (because my only card on file has now expired, I presume) so there is no where to go.

Okay then…. I type in the pay pal URL and start from the beginning. I log in, find the card and attempt to edit it. I Update the expiry date and the CVV number and attempt to save the changes. Now, it doesn’t like my billing address. The same billing address it happily accepted when I moved house 9 months ago.

I get an error message that states:

We were unable to verify the billing address for this credit card. Please enter the address where you receive billing statements for this credit card below. Please refer to the automatic email we have sent to assist you.

The address they have on file is my address, and it is the address my credit card bill comes to.

Interestingly I’ve attempted to update the expiry date several times over the last hour and so far I’ve receved a sum total of zero emails from Pay Pal. I’ve even sent them a message to their support centre, and not even as much as a we’ve confirmation of receipt.

Was the address on file wrong? Well, appart from one comma there was no difference to the address they have an how the address is printed on my credit card statement. So, I retype the address with out the comma and it still doesn’t work.

Anyway, I’m going to have to think of other ways to pay as I don’t want the seller getting pissed off and think I’m a bad customer who won’t pay.

Why is it that every time I use Pay Pal it is a bad experience?


NOTE: This blog entry was rescued from the Google Cache. The original entry was dated Sunday 3rd June 2007.

Developer Day Scotland

There will be a DDD (Developer! Developer! Developer!) style event in Scotland some time soon. In other words it would be on a Saturday. It would last the whole day. There would be different tracks so you could pick and choose what you wanted to see. The atmosphere would be great!

There have now been 4 very successful developer days held in Reading and a fifth one on the way. I can’t wait to get down there, but the travel is a bit of a hassle. It is over 400 miles. If it was closer to home it would be much better.

So, the call is out! If you are interested in a Developer Day Scotland then respond to this thread on the Scottish Developers website:

Alternatively, drop us an email at dds AT scottishdevelopers DOT com

The current ideas floating around would be to do this three months out of phase with the Developer Day held at TVP in Reading so they didn’t clash. It would also give people the opportunity to attend both if they wanted – There are a fair few people from Scotland travelling down to Reading for the existing DDD, so why not have some folk from the south of England travelling north to Scotland too?

At the moment we are looking out for sponsors to help pay for it all. We would like to keep it free if we can.

So, get the message out. There will be a Developer Day in Scotland! And you’re all invited.


NOTE: This blog entry was rescued from the Google Cache. The original entry was dated Friday, 8th June 2007

Old blog fell off the net

My old blog fell off the internet about a week ago. I’m not sure what happened. The server seems to be dead. Oh well…

What will follow is a dump of some of my old blog entries that I managed to rescue from the Google Cache. Then normal service will resume.



WARNING: Incoming rant.

As you know, I help out on forums from time-to-time… Well, a lot actually. But sometimes people just don’t seem to want to give up the most basic of information which might help diagnose the problem.

I’ve blogged about this in the past and this example, especially the response to my initial question, shows the utter uselessness of the information given.

Eejit: My stored procedure doesn’t work. It has an error.
(A stored procedure was listed with no obvious point of failure)

Me: What is the error?
Eejit: The error code is not zero but another number.
(Note: Zero = success, an other number indicates various types of error)
Me: What is the error code given?

At this point I just want to give up in dispair. Do these people go to their doctor and say simply: “I feel unwell. It hurts.” And then where the doctor asks where they respond: “Somewhere on my body.” Do they expect their doctor to diagnose them with that level of information. Maybe they should have seen a vet – at least then they could have been put out of their misery!

NOTE: This was rescued from the Google Cache. The original was posted on Sunday, 18th March 2007

Original Comments:

It doesn’t matter when you see the doctor as you’ll be going away with a prescription for Asprin or Paracetomol!

At some point you just need to say, sorry I can’t help you if you’re not able to help me to understand your problem. Perhaps you’d like to try another forum!

3/28/2007 9:57 PM | John A Thomson


It usually comes down to that. I do have to bite my tongue (or fingers in this case) as I try not to sound too irritated. Which is why I occasionally have to vent on my blog.

3/28/2007 10:14 PM | Colin Angus Mackay


When I was active in the newsgroups/forums I got this kind of frustration so often that in the end I created a set of rules and posted them to my blog. Next time someone broke a rule, I would reply with just the URL to the rules and nothing else. Soon other MVP and MSFT support people started doing the same:

4/19/2007 10:08 AM | Daniel Moth