Today’s post on the Android Developers Blog annoys me. Titled Integrating Application with Intents, it describes pretty awesome mechanism by which one app can re-use parts of another app’s code, provided both are structured properly.
If you’re technically inclined, head over to that blog for the nitty-gritty of things. It’s pretty well done — and obviously not the part that annoys me.
What bothers me is that despite having come up with such a great mechanism for code re-use, Google have missed two vital bits to make the whole thing useful:
- There are no standards for Intents.
- You cannot model dependencies on Intents.
Let’s take PackRat as an example: it re-uses code from the fantastic Zebra Crossing project in order to let you scan barcodes of your favorite media items. Yet it reuses them in a primitive fashion without using Google’s Intent mechanism. Rather, code is duplicated between the two projects.
The reason for that is simply user comfort — that is, yours. While it’s entirely possible to rearrange PackRat’s code to use the Barcode Scanner app from the ZXing project for scanning instead — via Intents — the simple fact is that you’d need to install both in order for PackRat to unfold it’s full potential.
Unfortunately I cannot mark PackRat to be dependent on the Barcode Scanner app in such a way that you’d automatically install one if you also install the other.
Which is fine, if you’re an Android geek. It’s not fine if you’re my mum. While she wouldn’t necessarily find any use for PackRat, the sentiment that she should be able to use it if she wanted to remains valid. Why place a higher burden on users than strictly necessary?
Modeling dependencies between software packages is essential if you want code re-use and user comfort. Google seems to have missed out on that opportunity so far.
In PackRat’s feedback forum, someone fairly empathically argued that I reuse Barcode Scanner anyway — and I even agree with the principle of it. One of the things they argued for, though, was that by decoupling PackRat from the actual scanner app used, people could pick their favourite app for that task.
Unfortunately, that’s just not true. Any Intent for scanning I might use would certainly be understood by ZXing’s Barcode Scanner, but not by any other. That’s because ZXing came up with the Intent and parameters to use by themselves. While they may have documented their approach fairly well, there is no guarantee that any other developer would provide a compatible app.
Standards are never guarantees for that, granted. But at least they provide some form of pressure for developers to either conform or publicly document a competing, potentially better standard. Right now, in the Android developer community, there is neither.
Android needs standards for Intents, and similar means for apps to interact. OpenIntents.org makes a passable attempt at documenting what apps do and expect out there, but that’s not the same as Google endorsing them as standards — not by a far cry.
So Google’s blog entry annoys me. On the one hand, they’d like to encourage us to re-use code, and have even provided a clever approach to facilitate that. On the other hand, their support falls woefully short of enabling developers to provide true integration.
In the end, the decision to duplicate code rather than re-use it more elegantly was clear: user experience comes first. And for the time being, that’s better achieved by more primitive means.