S h o r t S t o r i e s

// Tales from software development

Archive for October 2008

Terms of engagement

leave a comment »

After a long project based at Microsoft’s Thames Valley Park (TVP) campus, I started a new assignment a couple of weeks ago with a company that pitches itself as an online retail innovator. I guess I’ve been spoilt by my time at TVP because the working environment at my new assignment makes for a poor comparison despite the company’s attempts to make it a “cool” (sic) place to work.

The working environment at TVP is probably about as good as it gets but what is really striking is what it actually achieves.

Ask someone who’s been at TVP for a few weeks what they think of the environment and they’ll tell you that it’s great that there’s free coke, fresh fruit laid out in the kitchens every morning, a couple of excellent cafeterias, a shop for day to day essentials, and numerous coffee bars. Visitors are often nonplussed by the number of relaxation areas with football tables, pool tables, XBox 360 consoles, etc. where there are always people taking a break from their work.

Ask the same question a few months later and you’ll generally get a different answer. It’s usually something along the lines of, “It’s an environment that enables me to deliver.” I’ve heard a number of people say this in more or less the same words. There’s an appreciation of the ‘free’ stuff and the facilities but, in the end, what matters most is the fact that all this adds up to freeing people to get on with their work.

It’s difficult to moan about your working environment when it’s close to perfect. And Microsoft really does put a lot of money into ensuring that you do have a good working environment. As an example, in the area where I worked every chair was a Herman Miller Aeron. If you’re not familiar with the Aeron, it’s a superbly designed and made orthopedic and ergonomic chair that retails for around £700 in the UK. It even has its own Wikipedia page. Obviously, Microsoft must have got a huge bulk discount but, nevertheless, it purchased hundreds of one of the best chairs around for its workers to sit on all day. By contrast, in almost every other environment I’ve worked in, I’ve been sat on a relatively cheap generic office chair that made my backside numb after ten minutes and gave me backache by the end of each day. How is that supposed to help me deliver ?

I struggle to understand how a company can spend upwards of £800 a day for a contractor on projects that might last for years at a time but then ‘save’ money by buying cheap office furniture and using old, underpowered, workstations running back level operating systems. 


Written by Sea Monkey

October 31, 2008 at 7:00 pm

Posted in Development

Tagged with

Do not return false to indicate a method nearly worked

leave a comment »

I’ve been tasked with resolving some bugs in the Order Management Processing System (OMPS) of an online retailer. The code was written three years ago in .NET 1.1 by a bunch of guys who were used to developing in Visual Basic 6.

One bug took about 2 days to diagnose because the manifestation of the bug was a long way downstream of the cause. The symptom was a string operation on a property that failed because the string was null. The actual cause was that the object that the property belonged to had been instantiated but not populated with data.

The path through the code that resulted in the exception was something like this:

    // Send a notification email
    if (user == null)
        user = GetUser();

private User GetUser()
    return new Logon(m_Accountid);

public class Logon
    public Logon(int accountId)

    private bool LoadData(int accoundId)
        if (DataAccess.GetUserDetails(accountId)
            // populate this object
            return true;
            return false;

What’s notable about this code is the way that it attempts to handle a failure to locate the requested details: the LoadData() method returns false. But there is very little that can be usefully done at this stage other than throwing an exception. Even worse than attempting to handle this situation by simply passing the problem back to the caller is that the calling code doesn’t bother checking the return value anyway but simply exits the Logon object constructor.

The result is that the code at the top of the call stack is given an instantiated but unpopulated object. This is worse than useless – it’s dangerous as the code will continue to execute with an invalid object. Sooner or later the code will probably fail. In this scenario the code in the SendEmail method fails because it cannot handle an email address of null.

I discussed this code with a colleague saying that I thought it was probably the worst .NET code I’d ever seen. He argued that he’s seen worse coding but then I pointed out that this wasn’t simply bad coding – this was a complete failure to use the .NET programming paradigm. The failure to access the user details in the LoadData() method is a perfect example of when and where an exception should be thrown but the programmer responsible instead used a return code to indicate failure but then didn’t actually bother checking the return code. This half-hearted approach results in an object that exists when it shouldn’t. Clearly the LoadData() method should either complete successfully or an exception should be thrown, returning false is neither useful or safe.

Written by Sea Monkey

October 26, 2008 at 8:00 pm

Posted in Debugging, Development

Tagged with

Be more effective

leave a comment »

Of all the C# books that I’ve read, Bill Wagner’s Effective C#: 50 Specific Ways to Improve Your C# stands out as one of the best. Each of the 50 topics covered is treated as a short essay and is written in a thought provoking and engaging manner. It also doesn’t matter too much about reading the topics in sequence so it’s easy to pick the book up, browse until you see something that interests you, and start reading. It’s one of the few books that I keep coming back to when I want to read something that might help me become a better developer.

The follow up, More Effective C#: 50 Specific Ways to Improve Your C# has finally been published and it arrived on my door mat yesterday. I pre-ordered it well over a year ago when it was due to be published in September 2007. The fact that it’s over a year late is, I suspect, mostly due to Bill having to play catch up with Microsoft as the new book was intended to focus on C# 2.0 but then C# 3.0 came along. The new book covers both versions 2.0 and 3.0.

I’ve only flicked through it and read the first 20 pages but, so far, it looks like a worthy follow up to the original book.

Written by Sea Monkey

October 23, 2008 at 8:30 am

Posted in Books

Tagged with

We're sorry, but MediaMax and The Linkup are now closed.

leave a comment »

If you used MediaMax or The Linkup then you probably already know that the company is no longer operating.

I started using StreamLoad about four years ago. I was working on a project where I was the only developer and the source code was on my laptop but not backed up anywhere. For my own peace of mind, as well as my client’s, I used StreamLoad to store daily backups of my work. At the time, the preferred way of doing this was to use the StreamLoad Uploader and Downloader tools. These were Windows applications that communicated with the StreamLoad website to, as you might guess, upload and download files.

Once that project was complete I never really used StreamLoad again and instead used local backup devices like external disk drives. But once in a while I’d visit the StreamLoad web site and login and check that my files were still there. 

StreamLoad became MediaMax and focused on hosting media files that could be linked to from your own web site. The StreamLoad tools still seemed to work and web site itself improved with a vaguely Windows Explorer like interface for managing your uploaded files. Then MediaMax became The Linkup.

I haven’t visited the StreamLoad web site for quite a while but I was still a bit shocked when I tried it last night and got an almost completely blank page but with these words in the centre of it:





We’re sorry, but MediaMax and The Linkup are now closed.




Apparently, The Linkup announced on July 10, 2008 that they would be ending the service on August 8, giving users less than a month to grab their files.

I doubt that I’ve lost anything that I didn’t have a copy of elsewhere but there must be a lot of people out there who have. If you run a quick search on the words ‘mediamax legal action’, you’ll get around 7,500 hits. Clearly, there are some very unhappy ex-MediaMax customers out there. I say ‘customers’ but that’s actually the problem – most of MediaMax’s users weren’t money-paying customers. Some were but the majority were users like me who made use of the storage facilities as a backup. StreamLoad’s original business model was based on the idea that you’d pay to download files if you needed more than 10mb at a time. So, they were never going to make money unless lots of their users kept losing files and needed to download the backups they’d uploaded.

The old adage that ‘if it seems to be too good to be true then it probably is’ holds true here but perhaps we should be more circumspect about other online data storage services too. There really isn’t any guarantee that any of these services won’t lose your data or go out of business in the long term. So, by all means go ahead and use online backup services but I, for one, won’t be relying on them totally…

Written by Sea Monkey

October 21, 2008 at 7:00 pm

Posted in Comment

Tagged with

A fresh pair of eyes…

leave a comment »

My first week on a new assignment and the first task I’m given is to look at a bug that’s been around for a few weeks that no one has made any sigificant progress on. The bug report looked like this:

Order Notes – Error on adding a note

2008-09-10: Ian

Go to search page
Search for an order number
Scroll to the bottom of the order and click the Add Note option
Enter some text for the note and click the Save button.

Expected outcome: Note saved

Actual outcome: An error occurred, please contact IT

2008-09-15: Richard

This bug is now resolved. Configurational issues in the test environment.

2008-09-16: Ian

Re-opened – bug still appears in test environment.

2008-09-19: Richard

Now fixed with latest deployment to test environment.

2008-09-22: Ian

Re-opened – bug still manifests.

2008-09-22: Paul

Issue is environmental. A script needs to be run to clear database schema locks on each deployment. Once script has been run this bug no longer occurs. Please ensure that this script is part of the deployment.

2008-09-23: Jim

I have successfully added notes without any changes to the environment. Perhaps a change in database permissions elsewhere has resolved the bug ? Please re-test.

2008-10-08: John

Error is still occurring. Looking at the code, the code most likely to be failing is the call to GetLoggedInUser() and GetLoggedInAccount(). We should investigate this code.

I chatted to one of the guys who had spent some time debugging this error and he told me that the bug was intermittant and that it generally didn’t manifest itself when the code was run in a debugger. So, I decided my first line of attack was to track down where the error message was being issued and simply look at the code to see if there was any obvious reason for an error to occur there.

Fortunately, the error message was hard coded in the source code and I could see that it was in the catch block associated with a try block with 5 lines of code:

User user = GetLoggedInUser()
note += "[" +  user.FirstName.Substring(0, 1) + user.LastName.Substring(0,3) + "] ";
note += "\r\n";
Response.Redirect("/Orders/ViewOrder.aspx?order=" + order.OrderNumber.ToString());

What immediately struck me were the two calls to the Substring() method in the second line. I doubted that there was any rule to enforce a FirstName of at least one character and a LastName of at least three characters. So, this code was going to fail whenever the FirstName was blank and the LastName was blank or less than three characters. 

I spent a few hours configuring the code so that it would run on my machine against the data in the test environment and confirmed that the Substring() calls were causing the error. The userid that the testers were using had blank FirstName and LastName properties and the following exception occurred:

Index and length must refer to a location within the string.
Parameter name: length

Sometimes it just needs a fresh pair of eyes to see the blindingly obvious…

Written by Sea Monkey

October 16, 2008 at 9:00 pm

Posted in Debugging

Tagged with

© Copywrong

leave a comment »

One lunchtime, a few years ago while working for another software company, I went for a walk and took several photographs of the company’s offices from a hill about half a mile away. A few days later I showed my favourite photograph, of the several I’d taken, to one of the company directors. He liked it and asked for a copy that he could use as the desktop wallpaper on his laptop.

I resigned from the company about three months later. Working there had not been a positive experience and after two years I felt that it was time to move on.

I’ve barely given the company a single thought since then but on a whim I looked at their web site recently and found that it was using my photograph on its ‘About Us’ page. Perhaps I should have let it go but it did seem wrong to me that a company that protects its copyrights so fiercely should indulge in unauthorised use and copyright theft like this. I’m sure they’d have a strong view on anyone ‘borrowing’ their software…

I sent an email to the director that I’d given the copy of the photograph to:

Subject: Photograph on web site
Date: Wed, 1 Oct 2008 19:25:06
From: seamonkey@xxxxxxxx.com
To: john@xxxxxxxx-xxxxxxxx.com

    one of my photographs is being used on your company web site. It’s the one at the top of the About Us page. Please could you remove it ?

Best regards

After a week or so I was beginning to think that my email was going to be ignored but then a response arrived:

Subject: RE: Photograph on web site
Date: Wed, 8 Oct 2008 11:18:25
From: xxxxxxxx@xxxxxxxx-xxxxxxxx.com
To: seamonkey@xxxxxxxx.com

I wasn’t aware that any photograph you took and gave me when you were working with us was subject to any copyright agreement. Can you let me know if this is in fact the case?


He was clearly implying that the photograph belonged to the company because I’d taken it while employed by it. While this might be a reasonable argument if the photograph had been taken while on company business in company time, this wasn’t the case. His logic would also mean that all my vacation photographs belonged to the company too! It’s very unlikely that a director of a software company is ignorant of the basics of copyright law.

Subject: RE: Photograph on web site
Date: 08 October 2008 13:46
From: seamonkey@xxxxxxxx.com
To: john@xxxxxxxx-xxxxxxxx.com

    it’s not my place to tell you about the ins and outs of copyright law but I’m sure that you appreciate that any material used commercially, such as on your company web site, is subject to copyright restrictions.

You asked me for a copy of the photograph for use as your desktop wallpaper on your laptop. I provided a copy of the photograph appropriately sized to 1024×768 pixels. This was for personal use, as you requested. It does not entitle you or anyone else to use it commercially.

As a director of a software company, I’m sure that you have a better understanding of UK copyright law than your response implies. I doubt that I need to say this but copyright protection in the UK is automatic and no registration of the right or the material is required. If you wish to know more then there are a number of guides to UK copyright law available online.

I have no desire to create difficulties for you and would be happy to resolve this by, for example, an agreement that the image is removed within three months.

Best regards

It might not be immediately obvious but I’d tried hard to make this email as neutral in tone as possible and to avoid antagonising the guy. Even so, I wasn’t expecting this to be easy. So, I was really surprised when this reply arrived a few  minutes later:

Subject: RE: Photograph on web site
Date: Wed, 8 Oct 2008 14:07:15
From: john@xxxxxxxx-xxxxxxxx.com
To: seamonkey@xxxxxxxx.com

I haven’t got the time to discuss the merits of copyright law in the UK at the moment, so we’ll remove it over the next couple of weeks.


I checked the web site a few weeks later and confirmed that my photograph had been removed. It had been replaced with a photograph apparently taken within the previous few days and while it was clearly not a ‘professional’ shot, it was a competent image that showed the company’s offices to much better effect that ny photograph had. It was exactly what they should have done in the first place!

Written by Sea Monkey

October 14, 2008 at 9:00 pm

Posted in General

Tagged with

The king is dead, long live the king!

leave a comment »

This week saw the first release of a new tasks library for MSBuild.

MSBuild Extensions Pack

The MSBuild Extensions Pack can be downloaded from CodePlex. If you browse the project page you’ll quickly see that this is a repackaging of an earlier tasks library called FreeToDev. You may also recognise the name of the project co-ordinator as Mike is also currently also the co-ordinator for the SDC Tasks Library on CodePlex.

A short history

Considering the power and flexibility of MSBuild and the ease with which tasks can be written to add to its functionality, it’s surprising that there are so few task libraries available. A couple of years ago (2006) a bunch of guys at Microsoft UK created the Solutions Build Framework (SBF). This was a build framework of MSBuild targets and tasks that could be configured to run daily, continuous, buddy, and developer builds. The SBF was built on the functionality of a tasks library known as the SDC Tasks Library (named after the Solutions Development Centre at Microsoft UK). The SDC Tasks Library could be used as a standalone MSBuild tasks library if you didn’t want to use the SBF.

The SBF was a very powerful build framework that was used on a number of large scale projects within Microsoft. It was made available for download from http://www.GotDotNet.com in 2006. It was always a work in progress not least because it was largely maintained and developed in the contributor’s own time. 

In May 2007 the SDC Tasks Library was moved to CodePlex when GotDotNet was phased out but the SBF was not migrated. The problem was that the SBF was incomplete, difficult to maintain, largely undocumented, and quickly becoming outdated. So the decision not to move it to CodePlex is understandable but is a great shame because, as far as I’m aware, there is nothing of comparable scope and power to replace it.

The SDC Tasks Library is maintained but little is being done to add to its functionality or to keep it up to date. Again, this is understandable as there is little incentive to continue developing it now that the SBF is no longer available and Microsoft’s preferred build tool for internal projects is Team Build.

So, with the release of the MSBuild Extensions Pack, it’s good to see a new initiative that may eventually offer all the functionality of the SDC Tasks Library and more.

Reinventing the wheel

The biggest problem in maintaining the SDC Tasks Library was that it needed refactoring but backward compatibility was the highest priority. These aren’t incompatible needs but they do make for difficult bed fellows, especially when the project was being maintained in the contributors’ own time.

Perhaps the best way forward would be to create a completely new version of the tasks library that rationalised the tasks at the expense of backward compatbility. SDC Tasks Version 2.0 ? Well, perhaps that’s what the MSBuild Extensions Pack is. Yes, a lot of functionality from the SDC Tasks Library is missing but, hopefully, this will be migrated in the future.

Other task libraries

Another task library is being developed at Tigris.org. The MSBuild Community Tasks Project is another collaborative effort to create a general purpose MSBuild tasks library. I’ve been working with this library over the past week and it looks promising, if a little immature in some areas.

As far as I’m aware, as of now, October 2008, there are no other MSBuild task libraries of the scale of these three projects. There are a few task related resources but none that I’d recommend without reservations.


SDC Tasks Library

MSBuild Extension Pack

MSBuild Community Tasks Project

Written by Sea Monkey

October 11, 2008 at 12:05 pm

Posted in MSBuild

Tagged with