ToString() and cultural insensitivity

It was a scramble going through my entire code base. We’re talking thousands and thousands of lines of code here.

Luckily there was the Find function. And that the search string was fairly unique. And that the code change was fairly contained.

So what was I getting all hyped up about? Someone submitted a bug report telling me the SetRowHeight() function of my spreadsheet library didn’t work. What?!?! I tested that thing and it worked fine!

“What do you mean by it didn’t work? Was the row height changed to a wrong value, or something else” I asked.

“It completely failed. I can’t even open the Excel file.” was the answer.

Oh cranberry. Oh flying fishball hashbrown cranberry.

So I asked the person to send me the resulting Excel file that was generated. I looked through the contents, and found this: “40,2”

Shouldn’t that be “40.2”, I wonder.

And then I looked at the person’s name real close. I guessed the person’s somewhere in Europe that uses the comma as a decimal point character and the period as the thousands separator.

I proceeded to set every numeric variable that uses the ToString() function to have ToString(System.Globalization.CultureInfo.InvariantCulture). There were other changes I made based on this knowledge, but that ToString() was the main change.

Now this isn’t a post telling you about ToString() and thinking about how your program works in different cultures and so on (The biggest one I know is the Turkish “i”. That one seems to be a nightmare for upper and lower casing changes). The lesson I want to tell you is that no matter how much you check your software, the moment an actual user (in my case, a programmer) uses your software, shiitake mushrooms hit the fan.

You will only really know how good your software performs when other people are using it. You have no idea where they’re using it (like in my case), how they’re using it, or even why they’re using it. This means the sooner you put your software out there, the sooner you know whether your software is actually useful.

It doesn’t mean put out sloppy work. It just means you put out work that’s done to the best of your abilities, regardless of how small that feature list is. If it’s a bug tracking software, make sure it can track bugs easily. If it’s a shoot-em-up game, make sure I can run around easily and shoot enemies/monsters/aliens (fairly) accurately. If it’s a calculator, make sure it can at least add, subtract, multiply and divide before doing all those scientific and accounting functions.

So what software projects are you working on right now? What can you cut out so you can devote more energy to the core of your software?