Having to maintain apps on more than one platform is a major pain for developers. When building its new Inbox app, Google came up with some interesting strategies to maximise the amount of code reuse it could achieve.
Inbox runs on the web, as an Android app and an iOS app. That demands very different approaches; iOS apps, for instance, are usually written in Objective C (though Apple does support other options). The interface conventions on platforms also differ -- Android phones have a back button, for example.
Google engineering director Garrick Toubassi details how Google tackled building Inbox in a blog post that went live today. The whole thing is worth reading, but the central insight is that Google cut down on the need to write large amounts of code for each platform by first of all building a server-side data model in Java that defined the concepts used in Inbox (such as conversations and reminders). Each platform implementation could then draw on that model:
If you’re building an application that (a) has significant UI independent client logic, (b) is targeting multiple platforms, (c) must not compromise on user experience and polish, you now have a new option to consider: a shared, cross compiled data model powering fully native application UIs. This has worked well for Inbox, where we are sharing roughly two-thirds of our client code, and have delivered a product with the same functionality and ship date, without having to rewrite the entire thing three times.
That approach still demands significant resources, and few developers will have the luxury of a Google-sized budget. Hit the link to read the full post, including detailed discussions of how Google handled some language—level differences.
Going under the hood of Inbox [Official Gmail Blog]