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

How not to fuckup with building mobile SDK and make clients happy (DevFest Prague)

How not to fuckup with building mobile SDK and make clients happy (DevFest Prague)

Are you working on the client library? Or design a public API for the module that is going to be used by other team or department?

In this session, Vitality will share his experience and key learnings from building a mobile SDKs for last 4 years.

Vitaliy Zasadnyy

November 04, 2017
Tweet

More Decks by Vitaliy Zasadnyy

Other Decks in Technology

Transcript

  1. @zasadnyy
    With building the mobile SDK
    How not to Fuck Up
    Vitaliy Zasadnyy
    Head of Mobile @ GetSocial

    View Slide

  2. @zasadnyy
    Integrated SDK.
    But it doesn’t work.

    View Slide

  3. Developer.
    GDG Lead.
    Public Speaker.
    @zasadnyy

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. @zasadnyy
    UNDERSTANDING “WHY?”
    BETTER DEVELOPER
    MAKES YOU A

    View Slide

  8. @zasadnyy
    My first library…
    Develop

    View Slide

  9. @zasadnyy

    View Slide

  10. @zasadnyy
    SDK Lifecycle
    Develop
    1

    View Slide

  11. @zasadnyy
    SDK Lifecycle
    Develop
    1
    Integrate
    2
    Support
    3
    Update
    4

    View Slide

  12. Develop
    1

    View Slide

  13. Integrate

    View Slide






  14. android:name="im.getsocial.sdk.invites.ImageContentProvider"
    android:name="im.getsocial.sdk.AppId"
    android:value="LuDPp7W0J4"/>









    GetSocial.init()

    View Slide






  15. android:name="im.getsocial.sdk.invites.ImageContentProvider"
    android:name="im.getsocial.sdk.AppId"
    android:value="LuDPp7W0J4"/>









    View Slide

  16. @zasadnyy
    Android manifest merging
    App manifest
    Lib 1 manifest Lib 2 manifest Lib N manifest

    View Slide

  17. @zasadnyy
    Gradle plugin
    apply plugin: 'im.getsocial'

    View Slide

  18. @zasadnyy
    Gradle plugin
    apply plugin: 'im.getsocial'
    getsocial {
    appId "LGa80P9790xsg4"
    }

    View Slide

  19. @zasadnyy
    Android Studio plugin

    View Slide

  20. @zasadnyy
    Android Studio plugin

    View Slide

  21. @zasadnyy
    Auto initialisation
    android:name="im.getsocial.AutoInitContentProvider"
    android:authorities="..."
    android:exported="false" />

    View Slide

  22. @zasadnyy
    Boilerplate ➡ Copy/Paste ➡ Bugs
    Why?

    View Slide

  23. @zasadnyy
    IS BETTER
    LESS CODE

    View Slide

  24. @zasadnyy
    API SURPRISES
    AVOID

    View Slide

  25. @zasadnyy
    Avoid API surprises
    Thread.interrupted()
    Returns the current interrupted status
    and then clears it

    View Slide

  26. @zasadnyy
    Avoid API surprises

    View Slide

  27. @zasadnyy
    Avoid API surprises
    Thread.interrupted()
    Returns the current interrupted status
    and then clears it

    View Slide

  28. @zasadnyy
    Make API of your library
    as boring as possible
    - Chris Sells, Google

    View Slide

  29. @zasadnyy

    View Slide

  30. @zasadnyy
    INTERNALS
    HIDE

    View Slide

  31. @zasadnyy
    Hide internals

    View Slide

  32. @zasadnyy
    Hide internals
    Use .internal package
    Keep everything private by default
    Bonus: easy to generate Javadocs

    View Slide

  33. @zasadnyy
    There is much more!

    View Slide

  34. @zasadnyy
    ?
    Library is crashing
    your app?

    View Slide

  35. @zasadnyy

    View Slide

  36. @zasadnyy
    CRASH HOST APP
    NEVER

    View Slide

  37. @zasadnyy
    Prevent crashes
    Rx
    @Nullable / PMD / FindBugs / Lint
    Development Mode

    View Slide

  38. @zasadnyy
    Development mode
    if (BuildConfig.IS_DEVELOPMENT) {
    _executionPolicy = new StrictExecutionPolicy();
    }

    View Slide

  39. @zasadnyy
    Development mode
    if (BuildConfig.IS_DEVELOPMENT) {
    _executionPolicy = new StrictExecutionPolicy();
    } else {
    _executionPolicy = new SilentExecutionPolicy();
    }

    View Slide

  40. @zasadnyy
    SUPPORT

    View Slide

  41. @zasadnyy
    Give a voice to your users
    GitHub issue tracker
    Intercom
    Support email

    View Slide

  42. @zasadnyy
    Get ready to repetitive
    questions

    View Slide

  43. @zasadnyy
    DOCS

    View Slide

  44. @zasadnyy
    Documentation is like sex.
    Even bad is better than nothing

    View Slide

  45. @zasadnyy
    Key parts
    Step by step tutorials
    Product guides
    API Reference

    View Slide

  46. @zasadnyy

    View Slide

  47. @zasadnyy

    View Slide

  48. @zasadnyy

    View Slide

  49. @zasadnyy
    What is wrong with snippet?
    CurrentUser user = getSocial.getCurrentUser();

    View Slide

  50. @zasadnyy
    What is wrong with snippet?
    CurrentUser user = getSocial.getCurrentUser();

    View Slide

  51. @zasadnyy
    ALL SNIPPETS MUST
    COMPILE

    View Slide

  52. @zasadnyy
    Better snippet
    import im.getsocial.sdk.GetSocial;
    import im.getsocial.sdk.CurrentUser;
    ...
    CurrentUser user = GetSocial.getInstance().getCurrentUser();

    View Slide

  53. Google Developers Documentation Style Guide

    View Slide

  54. @zasadnyy
    Documentation engine
    GitHub Wiki
    Jekyll
    MkDocs

    View Slide

  55. @zasadnyy
    ?
    Favourite source
    of copy / paste code?

    View Slide

  56. @zasadnyy

    View Slide

  57. @zasadnyy
    DEMOS

    View Slide

  58. @zasadnyy
    Demo apps
    Make demos well documented
    Keep SDK integration code separated

    View Slide

  59. Support

    View Slide

  60. @zasadnyy
    ?
    You’ve got support request.
    Now what?

    View Slide

  61. @zasadnyy
    Two types of problems
    Integration time
    problems
    End-user side
    problems

    View Slide

  62. @zasadnyy
    Easy way to collect DEBUG information

    View Slide

  63. @zasadnyy
    Debug SDK configuration
    adb shell setprop debug.getsocial.sdk.app com.demo

    View Slide

  64. @zasadnyy
    Actionable errors
    public class GetSocialException extends RuntimeException {
    private final int _errorCode;

    }

    View Slide

  65. @zasadnyy
    Actionable errors
    public class GetSocialException extends RuntimeException {
    private final int _errorCode;

    }

    View Slide

  66. @zasadnyy
    Solving end-user side problems
    Comprehensive logs
    Errors analytics

    View Slide

  67. @zasadnyy
    Solving end-user side problems
    void trackError(GetSocialException exception) {
    ...
    AnalyticsTrackManager.trackAnalyticsEvent(
    AnalyticsEventDetails.Name.SDK_ERROR,
    eventProperties);
    }

    View Slide

  68. @zasadnyy

    View Slide

  69. @zasadnyy

    View Slide

  70. @zasadnyy
    THINK ABOUT SUPPORT
    AHEAD

    View Slide

  71. Update

    View Slide

  72. @zasadnyy
    ?
    Just download and lean
    back?

    View Slide

  73. @zasadnyy
    Update. Build. And…

    View Slide

  74. @zasadnyy

    View Slide

  75. @zasadnyy
    UPDATES
    SMOOTH

    View Slide

  76. @zasadnyy
    Backward compatibility
    Use @Deprecation cycle
    /**
    * @deprecated use {@link #getAllIdentities()} instead.
    * Method will be removed in SDK v5.0.0.
    */
    @Deprecated
    public List getIdentities() { ... }

    View Slide

  77. @zasadnyy
    Semantic versioning
    v4.5.1
    Major Minor Bugfix

    View Slide

  78. @zasadnyy
    Versioned packages
    import okhttp3;
    import im.getsocial.sdk6;

    View Slide

  79. @zasadnyy
    Versioned packages
    Partial transition
    A/B testing
    import okhttp3;
    import im.getsocial.sdk6;

    View Slide

  80. @zasadnyy
    Changelog
    Fixed issues
    New features
    Deprecations
    Upgrade guide

    View Slide

  81. @zasadnyy

    View Slide

  82. To sum up

    View Slide

  83. @zasadnyy
    PER APP
    17 SDKs
    Source: Safe SDK

    View Slide

  84. @zasadnyy
    SDK Lifecycle
    Develop
    1

    View Slide

  85. @zasadnyy
    SDK Lifecycle
    Develop Integrate Support Update
    1 2 3 4

    View Slide

  86. @zasadnyy
    API can be you biggest asset
    of liability
    - Joshua Bloch
    Put yourself
    in your customer’s shoes
    - Cesare Rocchi

    View Slide

  87. @zasadnyy
    Happy dog
    Make clients
    happy again.

    View Slide

  88. @zasadnyy
    Find me at:
    @zasadnyy / zasadnyy.com
    Questions?
    Děkuji!
    Get the app at:
    devfestcz.gsc.im/1/getamos

    View Slide