While working on some F#/C# WPF code the other day, I kept hitting a fatal FormatException when running under the debugger. Annoyingly, the app would quit with:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
But it worked fine when started from Expression Blend, or when run using Start Without Debugging in Visual Studio. Let’s take a closer look…
Read More
FormatException in WPF DataBinding
TwitterVision: How Twitter transformed TV
For a long time now, TV executives have bemoaned the lack of “event TV”. Modern broadcast television is a fractured ghost of its previous self. People’s attention is no longer focused in a tight beam on 3 channels; we have millions of videos at a click on YouTube, full-length TV shows and films on iTunes, hundreds of channels on satellite and cable. That means there’s no longer a significant section of society sharing the experience of a television show and discussing it the next day at school/the office water-cooler.
But what they seem to have missed is that something very different, but equally significant, has replaced it: the instantaneously-shared TV experience, enabled by Twitter. With the omnipresence of laptops, broadband and Twitter, the sofa’s now connected. It’s possible to sit at home on your own and discuss, berate and dissect whatever’s on RIGHT NOW.
Read More
What a response!
Wow. I’ve been totally overwhelmed by the response to the 7 signs your UI was created by a programmer: 40,000 readers and counting, and that was just over a couple of days! I’m expecting some seriously good programmer-created user interfaces after this. And if I spot one more typo in a dialog box, I promise I’ll raise an army of UI pedants to hunt you down and put your users out of their misery.
A couple of apologies are in order. Firstly, sorry if you tried to hit the site and found it down. I totally wasn’t prepared for the traffic; my bad. Secondly, sorry if you’ve posted a comment on the article here or elsewhere and I haven’t responded. I’m been swamped and the day job always seems to get in the way, dammit.
Anyway, thanks for reading, keep in touch, and I’ll try and get over that ‘difficult second album’ period I seem to be having.
Highlights from onedotzero – wow+flutter
I took a trip down to London’s Southbank on Sunday evening to see wow+flutter, a showcase of short, digitally-themed animations that are part of onedotzero, an annual festival and tour celebrating “adventures in moving image”. I’ve been several times before when it was based at the ICA (it’s now moved to the BFI National Film Theatre), and I always find it really inspiring. Normally, I can never remember the details of the films I’ve seen – it’s pretty intense; with over an hour of back-to-back shorts each lasting only 1-3 minutes – but this year they provided a list of the films details, so I can report on some of my highlights and provide links to some of the films.
The 7 signs your UI was created by a programmer
Do you suspect a programmer may have put together the terrible user interface on that “enterprise” software you’re forced to use every day? There are some give-away indicators. Look out for them in your software, hunt down the developer and force them to read a book about user interface design. If you’re suitably senior, force them to a) improve it, or even better b) get someone with real UI experience to fix it.
1. Exclamation marks in dialog box messages
Look, it’s probably the 50th time I’ve seen this message today. The fact that this application “Cannot connect to database!” is no longer a surprise. You may have noticed that most professional software uses a neutral tone for its communication with the user. Try that. Also:
1a. Double negatives in confirmation dialogs
“Are you sure you don’t want to lose your changes?” Err… what? No. I mean YES. Oh sh*t. Any dialog that requires you to stop and try to parse the question in order to work out if you’re about to destroy several hours of work is not doing its job. It’s getting in the way of you doing your job. In fact, convoluted messages are such a serious issue that Microsoft even tried to help developers to help their users by introducing a whole new kind of dialog box in Vista: the question/task dialog. Good luck with that.
2. No tab ordering defined\mouse only navigation
Because no-one’s ever going to use the keyboard to navigate the zillion controls in your data entry app, are they? This one actually surprises me, because I’d have thought that developers would’ve needed to navigate quickly through the application while they’re writing it. Well, that doesn’t seem to be the case. Pretty much all commercial apps are good counter examples. I don’t mean to hold up Microsoft Office as a paragon of UI virtue, but they definitely do the “alternate way of navigating everything” thing well. Everything you need can be reached by both keyboard and mouse. Unplug your mouse and try that with your favourite piece of in-house software and see how you get on.
3. Group boxes around everything
This is a bit of a WinForms specific one. The clue is in the name: group boxes are for grouping logically related controls, not for providing a kewl recessed border around every single one of the controls in your dialog. Don’t kid yourself that this is doing anything other than using up some valuable screen real estate. (See if you can spot another pet peeve in the example dialog, too).
4. Icons created in the IDE
Look, Visual Studio’s a really good integrated development environment, but it ain’t no Photoshop. Don’t try and use it to create icons. And while you’re at it, please don’t make icons consisting solely of the name of your application (inevitably an acronym) in pixel font and primary colours. Oh, and don’t just steal various icons from another application, unless you’re going to steal the whole lot; one of the key visual aspects of a good UI is consistency. Mixing your hand-drawn 4-bit icons with the glorious 32-bit shiny ones you borrowed is going to be jarring. In fact, why not go the whole way and get someone who can actually draw to create your icons for you? After all, you wouldn’t have someone who wasn’t a programmer writing the code, would you…?
5. Data grids
Otherwise known as the “Excel is the pinnacle of user interface design” disease. Break the habit. Generally, the more types of controls that are embedded in your grid, the less likely that it’s the right kind of interface paradigm. Yeah, I’m looking at you, person embedding a calendar control, drop down box, graph, slider and checkbox in each row of a data grid. And whatever your 3rd-party grid provider of choice says, it’s not going to do screen redraw performance any good, either.
6. Not implemented message boxes
Ahh, the GUI equivalent of source code TODO comments. Of course, it’s an in-house software give-away; no commercial (desktop) software would be brazen enough to ship with bits of functionality dangling from the stumps of buttons and menu items. Would it? Feel free to provide counter-examples if you have them.
7. Excessive use of dialog boxes
Warning: dialog boxes are considered harmful (to usability). They’re the equivalent of restraining your user by force and preventing her from moving until she answers your question. That might be OK for matters of life or death (i.e. data loss), but not otherwise. Every time you find yourself about to add a new message box, stop, take a deep breath and consider whether it’s really necessary.
So, if you’re a victim or one, many, or all of these user interface faux pas, all I can say is: sorry. I’ve been responsible for doing at least one of these things myself over the years. Consider this post repentance for my user interface sins.
Getting IUnknown from __ComObject
I’m working in an environment with a lot of mixed managed (F#) and unmanaged (C++ COM) code. One of the big problems with this is the mix of lifetime management techniques; .NET uses garbage collection while COM relies on reference counting. Furthermore .NET garbage collection is somewhat non-deterministic, which adds further complexity.
So quite often in our mixed code-base, we find that the .NET garbage collection process doesn’t kick in when we need it to. For instance, when we’ve allocated a lot of memory in the COM code that .NET isn’t aware of. Memory exhaustion has to get pretty bad for the GC to occur at any other time than during a .NET allocation, either the system-wide low-memory event has to be signalled or an OutOfMemoryException needs to be thrown. In both of these cases it’s probably too late to do anything about it.
In this case it’s extremely useful to be able to see what .NET objects are still alive, and what COM objects they’re hanging on to. Unfortunately this isn’t as easy as it might seem.
Read More
Missing content in long Wordpress posts
I’ve just spent several hours struggling with an annoying Wordpress problem: when I edited a post to make some additions, it suddenly stopped displaying any content. The title, header and footer were still visible, only the post body itself was missing.
After a bit of poking around, I came across this post. It points out the root cause of the problem is the PHP regular expression engine (PCRE) that Wordpress uses.
The easiest way to fix the problem is to ignore the advice in that post about modifying formatting.php, and instead make the fix to PHP.INI which is mentioned in the comments. I edited my copy to include the following line, which increases the backtracking limit from the default of 100000:
pcre.backtrack_limit = 1000000
After getting IIS to pick up the changes (iisreset) my missing content appeared again.
Finding the largest free block of address space
I’ve been seeing problems recently with fragmented virtual address space. During the lifetime of a process, bits and pieces of memory are allocated throughout the 2GB 32-bit address space to such an extent that large contiguous blocks of free space are no longer available. If anything subsequently requires a large block of memory (like, for instance, a somewhat out-of-date version of the GHC runtime), it will fail to get it.
It’s obvious looking at the output from VMmap or windbg’s !address command what the largest contiguous block is, e.g.
0:008> !address -summary .... Largest free region: Base 07300000 - Size 63ed0000 (1637184 KB)
But what if you need that number in order to make a decision at run-time? For instance, to decide whether your process is in a fit state to continue, or if it should instead commit hara-kiri. In that case, you need to access the information programmatically. That’s where the immensely useful VirtualQueryEx function comes in…
Read More
Diagnosing out of memory errors with VMMap
The other day a colleague pointed me to a new tool from Mark Russinovich et al (ex-SysInternals) that turns out to be very useful for diagnosing virtual memory/address space exhaustion issues. I thought I’d describe it here, and give some – hopefully useful – extra information on what it reports.
Ending the love affair with Excel
Unfortunately, given the ever-increasing focus on accountability and scalability in these domains, Excel is also an increasingly inappropriate platform for delivery of this sort of functionality. How can organisations ease the transition away from this environment to something more easily manageable, while retaining it’s positive benefits?

