Saturday, 23 January 2010

TDD FTW! - Android Cineworld App fixed in seconds

That is, Test Driven Development, for the win! =)

I just received an email from a confused user of my Cineworld Android application (UK only) telling me that it wasn't working. I was especially grateful though, as most people just change their rating to one star and leave a comment, but the Android market place doesn't push those comments to the developers.

Anyway, when the application loads for the first time it queries the Cineworld website for a list of cinemas, but in this case an error was occurring so the application was popping up a message saying "Unable to connect to server. Check your settings and try again later.".

At first I didn't think I had time to fix the problem but then I remember I had a bunch of unit tests for the application. So I loaded up the workspace and ran the tests and sure as hell, one of them failed.

But this was fantastic!

I could instantly see that the Cineworld's home page format had changed slightly and that might my app was unable to find the indicator it was looking for in order to extract the list of cinemas. Thankfully, it was only a change on the home page (they have installed some fancy-shmancy Javascript thing) and the 'cinemas' page still contained the list required by the application, so I only had to update the URL I was using, re-run my tests to verify and voila, a fix!

No complicated debugging session, or log viewing or anything like that. Just run the unit tests, make the fix, verify with the unit tests and job done - just the way it should be.


Peter said...


Is your Cineworld application available for direct download anywhere? It is not showing up for me in the market (possibly as I am in Ireland). I have developed my own application but I would like to see if yours has any ideas worth borrowing :)

Chris Brind said...

I'm afraid it's not available now.

I was screen-scraping the Cineworld website and it changes often enough to break my app without me noticing and i just get grief about it on the market place, so can't be bothered. :)

Plus their mobile site is pretty good anyway, though of course you need a data connection to use it. The only advantage mine had was that it cached the info offline.

But I was getting stupid feedback - for instance, if the app needed to get the latest info and the user didn't have a data connection, that was my fault for some reason... :)

Peter said...

Users can be a bit pants sometimes. Someone commented my app doesn't work on the HTC Desire but that is the only phone I can be sure it works on since that is what I have.

Cineworld have an API now and that is what I'm using. I screen scrape a lot of stuff but it is a real pain when people insist on changing their site and breaking my code. The API is a bit slow but I'm caching everything on the phone so that doesn't matter too much.

Chris Brind said...

That's good to know thanks - though I doubt I'll ever do anything with it again.

I approached Cineworld when I first started the app (must have been 18 months or so ago) for some support (financial or otherwise) and they just said "No thanks, we are building our own." by which I presume they mean the mobile site as I haven't seen an official Cineworld app on Android or iTunes yet. So I figured, why do all that effort for nothing a load of hassle from users?

Good luck with yours!