Generating and plotting random numbers

For a while now I’ve been planning to write a blog post about pricing financial instruments using Monte Carlo techniques in F#. As part of this I needed to generate normally distributed random numbers, and while putting together the code to do it I realised it was interesting enough to warrant its own post.

I’m making use of a few F#/.NET idioms to make the process easier. For instance, sequences (.NET’s IEnumerable) are used as the source of uniformly distributed random numbers. Also, to verify that the resulting numbers are actually normally distributed, we can easily use existing WPF/silverlight controls to visualise the values direct from within Visual Studio, in a manner similar to this previous post – but without having to write the plotting code ourselves.
Read More »

Posted in .NET, F#, Finance, Visual Studio, WPF | Tagged , , , | Leave a comment

Programming is like a bad analogy

The joy of programming is hard for anyone to precisely define. At least, it’s hard for programmers to define, and seeing as nobody else understands what the hell it is anyway, that’s pretty much the same thing. However a few people on the interweb have tried quite hard to describe just what the feeling of developing software is by comparing it to things in “the real world”.

A quick google reveals some of the funny, interesting and downright weird things that people have compared programming to. Let’s take a closer look at some of them…
Read More »

Posted in Rant, Software Development | Tagged | 4 Comments

Pinned DataTips in Visual Studio 2010 Beta 2

vs2010_pinned_datatipsI’ve just noticed a nice little feature in Visual Studio 2010 Beta 2: pinned DataTips. Values displayed in the debugger as you hover over a variable can now be pinned in place and remain aligned with the source. They can even have annotations added… Tasty!

Posted in Debugging, Usability, Visual Studio | Tagged , | Leave a comment

Comparing lambdas in C++ and F#

The other day someone pointed me to the new MSDN article on C++ lambdas in Visual Studio 2010. Interesting. C++0x has been a long time coming, but in my opinion anything that makes C++ usable at a higher level of abstraction is a good thing. There’s nothing wrong with a little abstraction, as long as you can get to the fundamentals if you need to. Otherwise you wouldn’t be using C++, would you?

But one of the things I couldn’t get over from that article is the verbosity. I’ve just got too used to the succintness of F#. I know this is only example code, so it’s intended to demonstrate usage, but the whole point of lambdas is to reduce boilerplate and make the intent of your code more obvious. So, let’s compare the C++0x implementation with the F# version.
Read More »

Posted in F#, Software Development, Visual Studio | Tagged , | 1 Comment

FormatException in WPF DataBinding

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 »

Posted in .NET, Uncategorized, Visual Studio, Windows | Tagged , , , , | Leave a comment

TwitterVision: How Twitter transformed TV

TwitterTVFor 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 »

Posted in Rant | Tagged , | Leave a comment

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.

Posted in Uncategorized | Leave a comment

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.

Read More »

Posted in Graphics | Tagged , , , , | 1 Comment

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.

groups3. 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).

icon_editor4. 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.

dialog_dialog7. 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.

Posted in Excel, Rant, Software Development, Usability | Tagged , , , | 43 Comments

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 »

Posted in .NET, COM, Debugging, Software Development, WinDbg, Windows | Tagged , , , , | 5 Comments
  • Follow me on Twitter Follow me on Twitter @voyce

  • Categories

  • Archives