07.09.09

SQHell

Posted in Development at 8:54 pm by Twm

Been doing quite a bit of SQL programming on and off. Although SQL is old as hell. MySQL on web and sqlite on mobile make it pretty much a compulsory skill for the modern developer to master for most types of data storage and retrieval.
Of course, SQL on its own means shit unless you spend some time designing a sensible schema which balances your normal form with your performance needs. Schema development can be really hard work to get right, and I find that it’s an iterative processes in which assumptions you make upfront turn out to be bogus or ineffective.
So to my delight, I’ve had to debug apps which just use a database as a dumping ground with no though to atomicity, poor rollback semantics and unjustified duplication of data across tables. The sort of thing you usually expect to see from an “enterprise consultant”.

The best illustration of the difficulty of expressing seemingly trival relationships between data is what has become known as the gay marriage problem (Or the Y2gay bug).

07.01.09

How to Shut a S60 application

Posted in Development, Mobile, Symbian, c++ at 2:41 pm by Twm

I have an application that needs to send a HTTP request on application exit to tell the server that the app terminated normally.
When the user presses the exit button, I issue an asynchronous request to send off a HTTP transaction and get a callback once that’s done.
Now the problem is, I want to really exit the application from my HTTP handler.
I can’t call CEikAppUi::Exit(), since this basically deletes the top level appUI and proceeds to pull the rug under the HTTP class which KERN-EXEC 3’s once my HTTP handler returns and reads/write some bit of memory that no longer exists.

Once solution is to create a CAsyncOneShot derived active object to cleanly exit, and luckily Nokia have already done this in a well hidden method:
Just call:

iAvkonAppUi->RunAppShutter();

The iAvkonAppUi is an ugly macro over CEikonEnv::Static(), so you can call it anywhere in your code.
THe app shutter allows the current call stack to unwind naturally and then exits the app.

06.23.09

All over the place

Posted in Development, complexity at 10:17 am by Twm

I’m doing some work with location based services at the moment. A colleague told me of some of the problems they had had with the software. One was related to the SkyHook system. This is the system that Apple used and helps to improve the speed of acquiring a fix by mapping the location of Wifi hotspots and cell towers.

the app would for the most part correctly report the position but during field testing- say when heading down the M25 – it would occasionally report the location as being back in central London. This erratic behaviour was a bit of a puzzle to the the engineers until they discovered that National Express have been installing Wifi access points on their buses.

05.10.09

OOM is dead (part 1)

Posted in Development, Uncategorized, c++ at 11:20 pm by Twm

When I joined Symbian in 1999, OOM (out of memory) and OOD (out of disk) testing was heavily engrained in the culture company’s as a continuation of the Psion product development activities.
Before I joined Symbian I was writing lots of Java code but had also written oodles of C code which didn’t bother to check the pointer from malloc().
My formative years at Symbian really taught me the value and skill of being able to write exception safe (and exception sensible) atomic/revertible state code. Although the particular dialect and naming scheme of Symbian’s exception handling framework (leaves, traps and the infamous clean-up stack) may not be the most popular, the general lessons learnt can be applied in any kind of software.

When writing software for an OS, it’s incredibly important to write robust code and consider every possible failure. As a pertinent example. I was assigned to fix a defect in customer’s phone in which the device sometimes failed to boot and had to be re-flashed – a problem that if happened on a consumer device may result in a costly replacement of the device at a service centre.

The bug was due to a customer modification of the phone application which was doing the following:
1. Write 80 bytes of data to a file during the shut down of the phone
2. Read 80 bytes of data from a file when the phone boots up

A very simple piece of code but the problem occurred when there was <80 bytes free. Lets say it managed to write 40 bytes.
When the device rebooted, it tried to read 80 bytes and got a Eofexception which propagated all the way up to the phone application’s constructor. Since the phone app is a critical process, the device tried to reboot in the hope that it would solve some issue.

Putting aside the inherent problems of having customers adding new code to system components. Once I found the offending code, It was pretty easy to deduce by sight that the code would fail under low disk, low memory and also fail in the case of a corrupted/zero length/missing file.
I probably spent a further hour or two fixing the code up and before releasing it, I wanted to test under low disk. I mapped the emulator’s C: drive to a USB pen drive and filled that drive with a dummy file which was just shy of the full capacity.
I then spent the rest of the day raising bugs against other components which stopped the emulator from loading in the OOD state.

Now you may ask what the value is in OOM and OOD testing now that mobile devices are packed with oodles of RAM and disk. And that’s a fair question. Aside from OOM and OOD still being a fairly common occurrence on mobile, the other answer is that is that it’s fairly easy to test OOM and OOD and code which deals with those conditions reliably is often better equipped to deal with any sort of failure.

This sort of thing is not very glamorous, but distinguishes* software engineering from hobby programming. As a core skill, exception safety and writing atom/transaction oriented code applies to anything from embedded code to the integrity of high bandwidth web back ends.
An astonishing amount of time is spent on phone projects trying to track down ‘mysterious’ unreproducible problems which turn out to be something similar to the above.

Just remember kids : Code that ‘mostly works’ is worse than code that doesn’t work at all.

*at least should

05.08.09

Search friendly APIs

Posted in Development, Mobile, c++ at 1:52 pm by Twm

Google is one of the best tools for a developer – particularly on mobile where APIs behave so erratically across devices. You can save an awful lot of time by searching for problems that other people have already encountered and solved (worked around or gave up).

I’m doing a bit of work on Java ME and Qt C++ at the moment and one thing that really struck me was how much easier it is to find example code, eratas and forum troubleshooting for Qt APIs.
Java APIs have fairly simple verb and noun naming scheme so you end up with very English “Object” and “Connector”, where as with Qt, all classes are prefixed with a ‘Q’.

Words beginning with anything other than ‘Qu’ are very rare in English (see here for a list of exceptions) so a search for QObject leads directly to the TrollTech site.

Forget semantic web – just come up with obscure prefixes for everything.

04.19.09

KAOSS PAD3

Posted in Development, Graphics at 7:32 pm by Twm

I’ve had a Kaoss Pad KP3 for a couple of years now. It’s a ‘hands on’ audio effects processor which has a touch pad that can be operated by fingers.
see the video below to get an idea:

The KP3 supports a MIDI out facility which pumps out MIDI events in response to touch pad or knob twist events. I’ve been meaning to write a driver program for this as I think there are some interesting possibilities in the field of live audio and video effects at events.

I quickly wrote a Processing program to listen for the MIDI events.
Read the rest of this entry »

02.24.09

Async or swim

Posted in Development, Mobile, Symbian, Uncategorized, c++ at 11:53 pm by Twm

In this article, I talk about the problems of wrapping asynchronous function to make them look synchronous. I first focus on the asynchronous APIs in Symbian OS and how synchronous waiting can be implement, and then discuss how Qt(TrollTech) have solved the same problem.
(This is still a bit rough, so I may make a few changes)
Read the rest of this entry »

02.23.09

Skids

Posted in AJAX, Development, Mobile, javascript at 2:46 pm by Twm

Last year, I wrote an article for the Reg about Google’s need for a mobile web platform which has Gears like functionality. There are a couple of ways of achieving this on S60, one is the Gears plug-in (a non starter on S60), develop your own browser (Firefox are doing this, and Chrome may or may not appear on mobile), or wait for the built in browser to implement the relevant HTML5 standards which allow interfacing with client side databases.

As I mentioned previously, the support for “canvas” tag in the HTML5 spec fills the need to draw arbitrary shapes, and Google demoed the potential of dropping Gears in favour of standard HTML5.0 primitives at MWC:

http://www.mobilecrunch.com/2009/02/18/video-offline-gmail-web-app-for-webkit-browser-phones-demoed/

So all this standards love in is all coming together nicely, with the palm Pre getting in on the action. But I found it hard to find information about S60’s web browser and HTML5 support, anyone know?

02.18.09

Enough!

Posted in Development, Mobile, Symbian, Uncategorized at 7:58 am by Twm

Eclipse is getting silly. What started off a fairly sensible tool for Java development now appears to have been designed for no one in particular. The problem is that every plugin thinks it’s the most imporatant thing in the system and splats itself all over the place. Sure you can say it support feature X, but and the notion of a co-ordinated design, a tool which crafted for the benefit of the developer seems to have been lost. It doesn’t even look like a tool ‘for developers, made by developers’.

Exhibit 1:
Here is the result of right clicking on an “identifier”. I was trying to look up a header file.

Woah! The list scrolls up and down on my laptop screen. And now with the Qt plugins, I now have around 50 tabs to choose from (all of which seem to jump around when i press them).
Ok, there are quite a few context sensitve options that belong in that list, but “Preferences” – that’s a global project option which doesn’t even refer to the file i’m editing, let alone the highlighted identifier, and why oh why is “Run Leavescan” there?.

No one could have designed this tool.

02.13.09

Symbian Wiki Opensearch plugin

Posted in Symbian at 9:42 am by Twm

I’ve made my developer.symbian.com Wiki search plug-in available on mycroft.
This plug-in adds an item to your Firefox3 or IE7 search bar, allowing you to search for FAQs, code clinics and other resources on developer.symbian.com.

It can be found here:
http://mycroft.mozdev.org/search-engines.html?name=developer.symbian.com

Incidentally, If you are a Welsh speaker you might be interested in these translation plugins:
http://www.twmdesign.co.uk/geiriadur/

« Previous entries Next Page » Next Page »