{
  "id": "e00a9eba94c4",
  "url": "http://www.tbray.org/ongoing/When/201x/2010/10/30/Three-Android-Software-Rules",
  "title": "Three Mobile-Software Rules",
  "note": "\nThese days, I spend quite a bit of time talking about how to write software\nfor Android. I think three of the general rules are worth expanding on here\nbecause I’m increasingly convinced they apply to software in general, not just\nfor mobile devices.\n\nCrash-Only\nAn Android app doesn’t need exit code.  You have callbacks for when you\nstart up, when you become active, and for when some other app takes your place and\npushes you aside; the latter two will typically be called repeatedly as the\nphone’s owner switches back and forth between apps.\n\nBut there’s no need for exit code because the system can, and does, nuke\nyour process any time you’re not active and it needs the memory.  What that\nmeans is that it’s your responsibility to save any state you might need in the\nfuture, and without asking anyone to select “File/Save”, either.\n\nAt some point, after I’d explained a few times why you have to write\nsoftware this way on Android, I started wondering why all software, without\nexception, isn’t written this way by default.\n\nLoose Address/Type-Driven Coupling\nThe way you hand off from one screen to another in Android is with an\nIntent.\nAn Intent has a Target, an Action, a URI, and a data type (as in Internet media-type, MIME\ntype), along with some ancillary stuff.  You can specify a target, essentially\na class name, and control passes to that class.  Or you can specify an action\n(make a phone call, view something, delete something) and its URI and or\nmedia-type, and let the system pick the right software to deal with it.\n\nSo, in your app, when\nwhenever your user taps on a URI, you fire off an Intent with the URI and the\n“view” action, and control passes to his or her favorite browser.\n\nThis has the nice side-effect of pushing you on the stack, so when the\nuser gets tired of browsing and hits the Back button enough times, eventually\nshe gets back to your app.  By fiddling media-types and actions, it’s dead easy for the\nuser to traipse naturally between Twitter, the browser, maps, contacts,\nphoto-browsing, music-listening, and so on, never losing the use of the\nall-important Back button.\n\nGosh, this notion of tying everything together loosely with addresses, data\ntypes, and a few simple verbs\nseems to have legs.  But since it\nwasn’t obvious to me from first principles that it would be a good way to\nconstruct mobile-device software, I’m wondering if maybe in general it’s a\ngood way to do almost everything.\n\nRemove Decoration\nWe advise people that, since mobile-device screens are small, that they\nhave to focus on data not decoration; get rid of all the headers and trailers\nand sidebars and toolbars that you can, so that the user gets the\nmaximum-possible amount of payload.\n\nComputer screens, whether desktop or laptop, are by comparison huge, and\nthis has led to a temptation to festoon interfaces with all sorts of\ndecoration and apparatus and gadgets and widgets and whatever.\n\nThe fact that on the mobile screen there’s just not room for that stuff\nmakes me increasingly wonder how much we really need it.  With every hour I\nspend traversing here and there on the Web, wincing away from sites that are\ndecoration-heavy and smiling at the ones that are all-message, the feeling grows.\n\n",
  "voice": "excerpt",
  "saved": "2010-10-30T19:00:00Z",
  "host": "tbray.org",
  "kind": "page",
  "tags": [],
  "record": "https://links.thingelstad.xyz/links/e00a9eba94c4/",
  "markdown": "https://links.thingelstad.xyz/links/e00a9eba94c4.md",
  "issues": [],
  "connections": {
    "same_host": {
      "count": 53,
      "page": "https://links.thingelstad.xyz/hosts/tbray.org/",
      "nearest": [
        {
          "id": "66c2519158e7",
          "title": "On Books",
          "url": "http://www.tbray.org/ongoing/When/201x/2010/09/26/On-Books",
          "record": "https://links.thingelstad.xyz/links/66c2519158e7/"
        },
        {
          "id": "0ab0f7c53483",
          "title": "What Android Is",
          "url": "http://www.tbray.org/ongoing/When/201x/2010/11/14/What-Android-Is",
          "record": "https://links.thingelstad.xyz/links/0ab0f7c53483/"
        },
        {
          "id": "05b07af1b1ea",
          "title": "Things about Blogging",
          "url": "http://www.tbray.org/ongoing/When/201x/2011/03/07/BNotes",
          "record": "https://links.thingelstad.xyz/links/05b07af1b1ea/"
        },
        {
          "id": "91a534a72394",
          "title": "Reshaping",
          "url": "http://www.tbray.org/ongoing/When/201x/2011/04/01/Straight-Right",
          "record": "https://links.thingelstad.xyz/links/91a534a72394/"
        },
        {
          "id": "c86e4afe2f51",
          "title": "A New HTTP Status Code for Legally-restricted Resources",
          "url": "http://www.tbray.org/tmp/draft-tbray-http-legally-restricted-status.html",
          "record": "https://links.thingelstad.xyz/links/c86e4afe2f51/"
        }
      ]
    },
    "same_week": {
      "count": 12,
      "nearest": [
        {
          "id": "edb451d967fb",
          "title": "3G now available on Mount Everest",
          "url": "http://www.tuaw.com/2010/10/29/3g-now-available-on-mount-everest/",
          "record": "https://links.thingelstad.xyz/links/edb451d967fb/"
        },
        {
          "id": "ebce5fb97a16",
          "title": "The 'Dancing Baby' Lawsuit Will Shape Future of Fair Use",
          "url": "http://gigaom.com/2010/10/29/419-the-dancing-baby-lawsuit-will-shape-future-of-fair-use/",
          "record": "https://links.thingelstad.xyz/links/ebce5fb97a16/"
        },
        {
          "id": "c46dbb670a1a",
          "title": "To rally, perchance to dream",
          "url": "http://buzzmachine.com/2010/10/30/to-rally-perchance-to-dream/",
          "record": "https://links.thingelstad.xyz/links/c46dbb670a1a/"
        },
        {
          "id": "81034e46509a",
          "title": "WELY End of the Road Radio",
          "url": "http://www.wely.com/",
          "record": "https://links.thingelstad.xyz/links/81034e46509a/"
        },
        {
          "id": "f213f8374d41",
          "title": "Funding Math and Science Projects For Young Women",
          "url": "http://avc.com/2010/10/funding-math-and-science-projects-for-young-women/",
          "record": "https://links.thingelstad.xyz/links/f213f8374d41/"
        }
      ]
    },
    "mentions": [],
    "mentioned_by": [],
    "saved_twice": []
  },
  "elsewhere": {
    "wayback": "https://web.archive.org/web/*/http://www.tbray.org/ongoing/When/201x/2010/10/30/Three-Android-Software-Rules"
  }
}
