Not long after My Bus Edinburgh 2.0 was released, I received an e-mail from a user who was a little uncertain about how the auto-refresh feature was supposed to work. A week or so later I received e-mails from another couple of users essentially asking the same question.
I thought it would be useful for me to share this question and my answer to people. The following is the question asked in the first e-mail. It has been edited slightly for spelling, grammar and clarity;
"I've played about with the application for the last couple of days. I can get auto-refresh to work. However, if I lock my phone, it goes to sleep or if I toggle to another app (leaving My Bus Edinburgh running) the auto-refresh feature seems to automatically switch off. So to keep it working I have to keep it in my hand and keep tapping to keep the screen active, which to me defeats the purpose a bit. If I have to stay in the app and keep tapping at the screen I might as well be tapping the refresh button?"The user of the application makes a valid point and I was happy to clear things up. Here is my response;
"This is how the auto-refresh functionality is intended to work. Let me explain;
When you navigate away from an application by pressing the home key or switching to another application, the application is put in to a 'paused' state. When you press the back key to get out of the application and you're in the root of the application (for My Bus Edinburgh, the home dashboard), the application is ended. If you switch back to the application, the application is 'resumed'. Unless the developer has put in any special background processing, the application will not do anything in the period of time it is paused.
Logically, you then might ask "so why not put in some background processing?". There are two reasons why this is the case;
1) Battery life. Transferring data through a 3G or Wi-Fi connection is consuming on the battery. A user may turn on the auto-refresh functionality and forget to turn it off again, meaning that the bus times are downloaded and processed every 60 seconds, until the the user turns it off, the app is killed or the device is restarted. This could go on for a long time, quickly draining the battery.
2) Strain on the bus tracker system. The application does not work out the bus times for itself, it downloads the data from the My Bus Tracker service provided by Edinburgh council. You may or may not remember, last winter the bus tracker system struggled to cope with the amount of requests for bus times and this made it to the Evening News. The council added in another server to cope with demand. Using the above scenario, if many people forgot to turn off auto-refresh then this would be a huge strain to the bus tracker system. The system already handles hundreds of thousands of requests per day for bus times.
The auto-refresh functionality is not touted as a major feature of the application. It's simply there as a utility function, to save people of the effort of manually hitting refresh. There's no point in the application downloading the bus times if the user isn't even going to look at them. That's why it only makes sense to do so when the user is actively looking at the bus times. Also, buses only update their position in the system every 30 seconds so constantly refreshing the data is unlikely to have much effect, until the bus publishes a new location in the system. I chose 60 seconds as a good balance between data freshness and not putting much strain on the system.
I hope my explanations above go some way to explaining why the auto-refresh functionality performs in the way it does."I am happy that I have got this answer out in public so that other people can see why this decision, although not immediately obvious, has been taken.