Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AndroidSummit2017_Best practices in building mo...

AndroidSummit2017_Best practices in building mobile libraries

Best practices in building mobile libraries

Emma Tresanszki

August 25, 2017

Transcript

42 slides
  1. VONAGE CONFIDENTIAL 3 • SDK vs Library • Developer perspective

    - managing dependencies - managing permissions • Creating Libraries - responsibility - failure handling - publish Agenda
  2. VONAGE CONFIDENTIAL 5 - A library < a chunk of

    reusable code > - An SDK < is still a library > (often with extra tool applications, data files and sample code) SDK vs Library
  3. VONAGE CONFIDENTIAL 12 - In Gradle, dynamic versions use the

    +sign - But what has changed? But which dependency?
  4. VONAGE CONFIDENTIAL 13 - Add nondeterminism to the build: -

    Behaviour changes - “But it works on my machine” - Difficult to revert - Fix it Dynamic dependencies are ‘evil’
  5. VONAGE CONFIDENTIAL 18 - I/O 2013 - /AndroidManifest.xml (mandatory) -

    /classes.jar (mandatory) - /res/ (mandatory) - /R.txt (mandatory) - /assets/ (optional) - /libs/*.jar (optional) - /proguard.txt (optional) - /lint.jar (optional) What is aar?
  6. VONAGE CONFIDENTIAL 19 - Fail fast when rejecting invalid params.

    Actually not all the time! - Do not discard future capabilities. - Flexibility: let the API handle rejections instead. Design phase: responsibility
  7. VONAGE CONFIDENTIAL 21 - 3rd party dependencies, or not at

    all - ex: libphonenumber in a 2FA phone verification SDK (~500kb) Design phase: library size
  8. VONAGE CONFIDENTIAL 22 - Devs should choose permissions - which

    features? - /AndroidManifest.xml - App to request permission grant - Library to check runtime permissions and block the feature otherwise. Design phase: permissions
  9. VONAGE CONFIDENTIAL 35 • Version numbers are used to encode

    compatibility for the API. • Semantic versioning {major}.{minor}.{bugfix} • Initial development phase: 0.1.0 • How to deprecate? ◦ minor ◦ major transition Versioning
  10. VONAGE CONFIDENTIAL 36 • Superstition ◦ Office 2007 internal v12

    -> Office 2010 has internal v14. ◦ Corel Graphic Suite v13 marketed as X3 ◦ Nokia jumped from S60 3rd -> S60 5th Edition Versioning
  11. VONAGE CONFIDENTIAL 38 How do I make a good CHANGELOG?

    Definition: A file which contains a curated, chronologically ordered list of notable changes for each version of a project. Principles • Changelogs are for humans, not machines. • There should be an entry for every single version. • The latest version comes first. • The release date of each versions is displayed.
  12. VONAGE CONFIDENTIAL 39 How do I make a good CHANGELOG?

    Group changes by type • ADDED • CHANGED • FIXED • REMOVED • DEPRECATED • SECURITY • UNRELEASED
  13. VONAGE CONFIDENTIAL 40 - Documentation - copy-paste a working demo

    - good API reference - advanced usage More stuff
  14. VONAGE CONFIDENTIAL 41 • Automated Gradle project deployment to Sonatype

    OSS repository • Maven Repository Usage Guide • http://www.leveluplunch.com/java/examples/parse-phone-number-from-string/ • http://www.theappguruz.com/blog/integrate-paypal-in-android//dropbox • http://blog.danlew.net/2015/09/09/dont-use-dynamic-versions-for-your-dependencies/ • https://github.com/olivierlacan/keep-a-changelog • http://skife.org/src/design/libraries/2011/12/14/library_versioning.html • http://keepachangelog.com/en/1.0.0/ • https://en.wikipedia.org/wiki/Software_versioning • http://blog.mockito.org/2014/10/maven-central-vs-bintray.html • https://developer.android.com/studio/build/manifest-merge.html References
  15. VONAGE CONFIDENTIAL 42 Thank you :) twitter @EmmaTresanszki Github @EmmaChristine

    slides Thank you! :) twitter @EmmaTresanszki github @EmmaChristine speakerdeck @EmmaTresanszki

More Decks by Emma Tresanszki

Other Decks in Programming