Architectural choices in mobile development - Gideon de Kok (PyGrunn conference)

Tags: python, pygrunn

Mobile: should we treat mobile clients different than regular “wired” webbrowser clients? Yes.

When you use a webbrowser you’re used to waiting a bit and submitting a form and waiting for the response and so. And the connectivity might be down for a while. The behaviour is synchronous. One action after the other.

On a mobile phone, you’re used to native apps and everything just works. So a web application “feels” different. The behaviour is asynchronous. You just send a tweet and it’ll submit itself in the background while you continue working.

Some tips:

  • Make your server do the work. Calculate on the server, don’t burn the mobile phone’s battery.

  • Cache a lot! What helps is local storage on the phone. Limit the amount of data that you need to send over.

  • Only refresh data periodically or on user request. Not all the time, if possible.

  • Queue and combine requests. Sending all the items one after the others often gives you a latency problem. Combining ten requests into one helps a lot. Queue up messages and post them in one go.

  • But…. Do Not Let Users Wait. Expensive stuff should happen in the background.

  • Don’t pull in too much over the wire. Small payload. Gzip. Less content. No unnecessary items. Restrict the bandwidth usage.

  • Adapt the payload. Depending on the connection speed, serve up different content. Text content on slow connections and video on wifi, for instance.

  • Use an API on the server. It decouples your server updates from client updates. And it often means less and more focused connections instead of raw database queries (yes, he saw that once…).

  • Never trust API input, though. Sanitize it. Check it.

  • Don’t store too secret stuff on the phone. It can get stolen or people can reverse engineer the data.

  • Never store a private key on the client when doing public/private key encryption. Keep the key on the server.

  • API? Just use some REST plus json.

At the end there was some discussion about mobile web apps versus native apps. A big problem with native apps is the fragmentation. Iphone is fine with just 3 models or so. But for android, to get the best experience, you basically need to take into account 800-1000 different models. That’s the best thing about mobile web apps: a decent html5+css3 web app generally works fine in most recent mobile phones’ web browsers. And you don’t have to go through the apple store…

Mobile bird logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):