All posts by Liam O'Donnell

O’Donnell’s 3 Laws of User Dynamics

Remember kids: You don’t have to please ALL your customers, just the ones you want to keep.

sheepThe first Law: conservation of users

Users are not created or destroyed, only converted to or from using a competitor’s product.

All other things being equal, you should remember that brand loyalty counts for less and less these days. If you don’t want to do what your users are asking for, maybe your competitors will.

polar bearsThe second law: the progress of disorder

Evolve your product, in order to fight ‘design entropy’.

As users’ needs change, so should your product. If you don’t have the right metrics in place, you won’t realise that your product is obsolete until you become the next Woolworths.

designThe third law: chasing perfection

Invent something idiot-proof and someone will invent a better idiot.

Humans are complex and often unpredictable. Therefore, human-computer interfaces are, at best, imperfect systems. Test your design assumptions and always have documented justification for design decisions that can be re-tested against new iterations of your product.

GuinnessPint

Wait for it…

Improving the usability of an interface, by making it do more or less what the user actually expects of it, is a pretty good route to an overall sound user experience. Yet, there’s one key mistake almost every interface I’ve looked at makes in this regard – what I call the Spurious Stimulus Response. That is…

responding to user input in the context of stimuli they haven’t been given the time to acknowledge.

For example, consider a dialog box, suddenly appearing centre-stage in an interface, as the result of an incoming message, error condition, or some such situation. If the user was to click on it, or press a key, within 250 milliseconds of it appearing, then they are not reacting to its appearance – instead they were probably intending to action something else.

In an interface without a pointing device, such as on TV, using a traditional remote control, the problem is exacerbated, since the user only need press OK to commit whatever action happens to come into focus. When using an infra-red remote control, this problem is compounded further, because it usually takes a fraction of a second for the receiving device to recognise the incoming IR pulses as something it needs to deal with and push that signal up through the software stack to the UI layer.

I suggest employing a simple fix, which draws its inspiration from the behaviour of nerve stimulation – called the refractory period. That is…

to render a control inactionable, after a change in UI state, long enough for the user to assimilate said state change.

The few interfaces which loosely employ some such technique, do so usually just as a side-effect of having some animated transition when a dialog appears, for example. Sometimes, a button or other control is disabled until the transition completes. This is actually a very good way of ‘easing the user into’ the change in UI state – but a refractory period should still be implemented where animation is absent.

The refractory period could be some function of the amount/importance of information provided. A good example of this is the Firefox Add-on confirmation dialog, which forces you to wait a few seconds, rather than letting you mash RETURN and install some random plugin.

But, in its most simple incarnation, a refractory period may simply be used to filter out double-click mania. Please start designing this kind of behaviour into your UIs – your users will thank you.

youview

Connected TV development with AIR for TV

Having just finished building the UI for the YouView set top box, I thought I’d share some of my insights into best practices when building applications for such resource constrained devices. The YouView UI is AIR based, written in AS3 and runs in Stagecraft 2, also known as ‘AIR for TV’. As the name suggests, AIR for TV is a special version of the Flash player for embedded systems, such as set top boxes. The first incarnation of the YouView UI (back when it was just codenamed ‘canvas’) was for Stagecraft version 1, which means coding in AS2 and suffering the abysmal performance that comes with running on AVM1 (ActionScript Virtual Machine 1).

Despite the delays and the need to code the UI from scratch in AS3, I think it was ultimately the right decision. Stagecraft 2 is a much better platform – Stagecraft 2.5.1 to be precise. It was a great opportunity to learn how to write optimal code and use hardware acceleration effectively on resource constrained devices. I’ll be doing some tutorials on this in the near future, but here’s the key points to observe when developing for such platforms:

  • Limit the complexity of your display list heirarchy
    This may sound obvious, but ensure you nest as few things as possible, keeping the display list as shallow as possible. Stagecraft needs to traverse through the display list, working out which areas of the screen to redraw. This is similar to how the desktop Flash Player handles redraws, but with some key differences to how it decides what needs redrawing, how it tackles moving display objects and how it delegates the work of updating the frame buffer – a subject for another time. Mostly importantly, if you’re developing for a resource constrained device (such as mobile or set top box), you’ll have very limited CPU power, even if the device’s GPU (graphics processing unit) affords you great hardware acceleration capabilities. So, before Stagecraft can delegate any work to hardware, it enumerates changes in the display list in software. Complex display list heirarchies are a headache for some of the low-powered CPUs found in mobiles and set top boxes and this’ll show up as rocketing CPU usage, low framerates and few spare ‘DoPlays’ in Stagecraft (spare work cycles). By keeping your display list shallow, with only the bare minimum of display objects on stage at any one time, you’ll be making life easier for Stagecraft by doing less work on the CPU – whether or not graphics are drawn in software or hardware.
  • Benchmark everything
    When building an application for a resource constrained device, you should be able to run each component in isolation, to assess its drain on CPU and system/video memory. There’s no point optimising the hell out of one component, when it’s actually another one that is the source of your performance bottleneck.
  • Know thine hardware acceleration capabilities
    There’s no point blindly using cacheAsBitmap and cacheAsBitmapMatrix everywhere, if it’s not going to speed things up on the target device. Worse still, too many cacheAsBitmaps and you may be just wasting valuable video memory, or causing unnecessary redraws (again, the subject of a future article). A lot of platforms will accelerate bitmaps, even if stretched, but not necessarily if flipped or rotated. Alpha on bitmaps (or anything cached as bitmap) will usually be accelerated too, but this is not necessarily the case with all colour transforms. Benchmarking any component you’re building will quickly tell you where you might have pushed it too far, but you should also have a way of verifying that a particular set of transforms is indeed hardware accelerated. Stagecraft provides this when using its –showblit command line parameter. I’ll be going into more detail about this in another post.
  • Mind your memory
    When using various hardware acceleration tricks, especially on resource constrained devices, video memory is at a premium and usually in limited supply. You will need to know the limits and have a way of seeing how much video memory your application is using at any one time – ensuring you dispose and dereference any bitmaps you’re finished with too. If your platform uses DirectFB for its rendering, as YouView does, the executable ‘dfdump’ can show you just where your video memory is going. This is something else I’ll get into in another article.
  • Blit blit blit
    This refers to blitting, where blocks of pixels are copied from one bitmap to another. This technique is used a lot in games, where graphics performance is critical, you should arm yourself with the basics of how old video games used blitting of multiple things to a single bitmap for performance and video memory efficiency.

I’ll probably go into more depth on each of these things in forthcoming posts. Stay tuned.

Chinese Handwriting Recognition App

Chinese Handwriting Recognition App

Unlike the iPad, the BlackBerry PlayBook has rather poor international keyboard support, with no method for entering chinese characters. I like the way iOS achieves this, so went about building my own version in ActionScript.

This was mainly an academic exercise and to help me to learn to write chinese. My approach was to sample the strokes drawn into the app as a series of up to 8 directions, including the relative position of a given stroke to the previous stroke, again as one of 8 directions. This pattern, represented as a string of numbers is then put through a smoothing algorithm, to remove some unnecessary noise and then compared with a dictionary of pattern keys, which may contain one or more suggested characters. If there are no hits, an advanced search occurs, by mutating the given pattern in specific ways, in order to find alternative suggestions. I can also find characters based on the next most likely character to the one you’ve just entered, using frequency analysis on given sample text.

The app will eventually be a PlayBook App, but is still unfinished and currently in ‘training mode’, so that character patterns can be trained into the database. It’s currently primed with some simplified sample data, from which it picks the most popular few characters to learn. If you write chinese, give it a go.

aliasAndAntiAliasComparison

SmoothBitmap – How to enforce pixel smoothing on a Bitmap

A common oversight when using Bitmaps with loaded content is that Flash will revert a Bitmap’s smoothing parameter to false when you replace its bitmapData. It’s simple enough to fix, but since you may not know if someone is going to replace the bitmapData of a Bitmap you have created – then it’s often better to code defensively around it.

This little SmoothBitmap class is for just such an occassion. Instantiate it like a regular Bitmap and, no matter what another developer does with it, smooth pixels when scaling/rotating will be ensured.

flip-table

CODING WRONGS – Where do I start with the bad?

It gets scary out there sometimes. During my freelance career I’ve worked at a lot of different companies and have seen such coding horrors as you cannot imagine. So I thought I’d start immortalising some of them – so that we can all learn better coding practices, by looking at the bad.

Starter for 10 – What’s wrong with this picture?

Did you spot the fubar? It’s not an obvious one.

This code potentially replaces a Bitmap’s BitmapData, without first explicitly disposing any existing BitmapData.

I see this kind of thing quite often and it’s the source of many a memory leak. AVM2 isn’t that great at dealing with this kind of situation and there’s a crucial difference between GC cleaning up out-of-scope objects for you and things like BitmapData: GC will reclaim the memory associated with objects ‘when it feels like it’, whereas explicitly calling the ‘dispose’ method of a BitmapData will immediately give you back that memory.

In the case of platforms with hardware accelerated graphics (such as mobile or set top box), the memory associated with the pixel data itself (video memory) will be reclaimed immediately.

The lesson?

Don’t make more work for the Garbage Collector when you can avoid it.