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

An Open Source Advantage (Droidcon MTL 2015)

An Open Source Advantage (Droidcon MTL 2015)

Video: https://www.youtube.com/watch?v=PCxz2LEmuL4

A successful app takes a lot of code. The best developers don’t write all of that code themselves; instead they rely on open source to solve all of the common problems. That way they can direct their energy on application-specific tasks.

In this keynote, we’ll show how to use open source effectively. We’ll start with guidance on evaluating a codebase. Then we’ll show you how to grow your relationship with an open source project, from user to contributor to maintainer.

We’ll talk about forking for good and evil, rejected pull requests, and how open source can lead to your code running on one billion Android devices.

Jesse Wilson

April 11, 2015
Tweet

More Decks by Jesse Wilson

Other Decks in Programming

Transcript

  1. an open source advantage
    @jakewharton @jessewilson

    View full-size slide

  2. Documentation

    View full-size slide

  3. Who do you work with?

    View full-size slide

  4. SOFTWARE
    DEVELOPER

    View full-size slide

  5. CUSTOMER
    PRODUCT
    EDITOR
    DESIGNER
    SOFTWARE
    DEVELOPER

    View full-size slide

  6. So you’re making a
    blue ribbon
    Android application
    Best
    PROGRAMMER’S
    RELEASE

    View full-size slide

  7. You’re going to need
    many libraries.

    View full-size slide

  8. • views: lists, sticky headers, layout binding
    • networking: HTTP client, image downloaders, REST adapter
    • data: JSON, protocol buffers, database access, value objects
    • monitoring: analytics, automatic & manual bug reporting, logging
    • development: debug utilities, static analysis
    • testing: UI, unit testing, mock objects, assertions, JVM testing
    • structure: dependency injection, async events, navigation

    View full-size slide

  9. • views: lists, sticky headers, layout binding
    • networking: HTTP client, image downloaders, REST adapter
    • data: JSON, protocol buffers, database access, value objects
    • monitoring: analytics, automatic & manual bug reporting, logging
    • development: debug utilities, static analysis
    • testing: UI, unit testing, mock objects, assertions, JVM testing
    • structure: dependency injection, async events, navigation

    View full-size slide

  10. {

    "baseUrl": "http://localhost:8080/cash/",

    "headerBackgroundUri": "/static/email/images/exampleBackground.png",

    "headerImageUri": "animatedHeader.gif",

    "theme": {

    "backgroundColor": "#ce0606",

    "textColor": "#ff6a5f",

    "buttonColor": "#ec2a2a"

    },

    "headerAlt": "$35",

    "title": "I embedded the background image in the HTML.",

    "button": {

    "label": "Thanks",

    "url": "https://cash.me/"

    },

    "showAboutFooter": false,

    "rightToRefundLink": false

    }

    View full-size slide

  11. Each library
    has many features.

    View full-size slide

  12. JSON library

    View full-size slide

  13. JSON library
    JSON writer
    JSON reader
    binding
    annotations
    m
    odel objects
    precision policy
    lenient policy
    binding system
    collections binding
    POJO
    bindings
    date
    bindings
    hash collision defence
    constructor caller
    code generator
    exception policy
    pretty printer
    benchmarks
    U
    TF-8
    transcoder
    type registry
    naming policy
    string pool
    error locator
    type resolver
    enum
    bindings
    cycle defense

    View full-size slide

  14. JSON library
    JSON writer
    JSON reader
    binding
    annotations
    m
    odel objects
    precision policy
    lenient policy
    binding system
    collections binding
    POJO
    bindings
    date
    bindings
    hash collision defence
    constructor caller
    code generator
    exception policy
    pretty printer
    benchmarks
    U
    TF-8
    transcoder
    type registry
    naming policy
    string pool
    error locator
    type resolver
    enum
    bindings
    cycle defense

    View full-size slide

  15. Each feature
    requires many
    lines of code.

    View full-size slide

  16. /**

    * Returns a JsonPath to

    * the current location in the JSON value.

    */

    public String getPath() {

    StringBuilder result = new StringBuilder().append('$');

    for (int i = 0, size = stackSize; i < size; i++) {

    switch (stack[i]) {

    case JsonScope.EMPTY_ARRAY:

    case JsonScope.NONEMPTY_ARRAY:

    result.append('[').append(pathIndices[i]).append(']');

    break;


    case JsonScope.EMPTY_OBJECT:

    case JsonScope.DANGLING_NAME:

    case JsonScope.NONEMPTY_OBJECT:

    result.append('.');

    if (pathNames[i] != null) {

    result.append(pathNames[i]);

    }

    break;


    case JsonScope.NONEMPTY_DOCUMENT:

    case JsonScope.EMPTY_DOCUMENT:

    case JsonScope.CLOSED:

    break;

    }

    }

    return result.toString();

    }

    View full-size slide

  17. Can’t build it all yourself!
    * Unless you’re in no hurry to ship.

    View full-size slide

  18. Open source
    offers many options!

    View full-size slide

  19. Guide to
    Jake & Jesse’s
    Evaluating Open!
    Source Projects
    Picasso, Volley,!
    Glide, & Fresco:
    Which one should!
    you avoid?
    Jason Parser
    With forward by Lynn E. R. Layout

    View full-size slide

  20. Right features

    View full-size slide

  21. read the code

    View full-size slide

  22. }
    dependencies {

    View full-size slide

  23. You just got
    thousands of lines of code
    for free.
    }
    compile 'com.google.code.gson:gson:2.3.1'
    dependencies {
    compile 'com.google.code.gson:gson:2.3.1'

    View full-size slide

  24. Put it to work.

    View full-size slide

  25. This is the best time to
    contribute documentation.

    View full-size slide

  26. Found a bug?
    Isolate it.

    View full-size slide

  27. Happy?
    Spread the love.

    View full-size slide

  28. You aren’t paying with money.

    View full-size slide

  29. You aren’t paying with money.
    Pay with your time.

    View full-size slide

  30. Let’s talk about
    contributing code…

    View full-size slide

  31. SMALL
    LIBRARY

    View full-size slide

  32. YOUR
    NEEDS
    SMALL
    LIBRARY

    View full-size slide

  33. JEN’S
    NEEDS
    YOUR
    NEEDS
    SMALL
    LIBRARY

    View full-size slide

  34. MARCOS’
    NEEDS
    JEN’S
    NEEDS
    YOUR
    NEEDS
    SMALL
    LIBRARY

    View full-size slide

  35. MARCOS’
    NEEDS
    MATT’S
    NEEDS
    JEN’S
    NEEDS
    YOUR
    NEEDS
    SMALL
    LIBRARY

    View full-size slide

  36. M
    ARCO
    S’
    N
    EED
    S
    M
    ATT’S
    N
    EED
    S
    JEN
    ’S
    N
    EED
    S
    YO
    U
    R
    N
    EED
    S
    BIG
    LIBRARY

    View full-size slide

  37. FEATURES YOU
    DON’T NEED
    FEATURES
    YOU NEED

    View full-size slide

  38. INCLUDE
    Code we all need.

    View full-size slide

  39. INCLUDE
    Code we all need.
    EXCLUDE
    Everything else!

    View full-size slide

  40. I wrote some new
    features for you!

    View full-size slide

  41. No thanks!
    I wrote some new
    features for you!

    View full-size slide

  42. No thanks!
    BUT THE CODE IS
    ALREADY WRITTEN!

    View full-size slide

  43. BUT THE CODE IS
    ALREADY WRITTEN!
    Ummm…

    View full-size slide

  44. EXTENSIBLE!
    Good APIs are
    EXTENSIBLE!

    View full-size slide

  45. OUR API MAKES
    YOUR CODE SIMPLE!

    View full-size slide

  46. OUR API MAKES
    YOUR CODE SIMPLE!
    AMAZE.

    View full-size slide

  47. AMAZE.
    PLUS WE’LL ADD IT
    AS A SAMPLE!

    View full-size slide

  48. (Designing extensible APIs is hard.)

    View full-size slide

  49. What to
    open source?

    View full-size slide

  50. Not another
    JSON library

    View full-size slide

  51. Not another
    JSON library
    * Unless you’re doing something new.

    View full-size slide

  52. Not another
    JSON library
    * Unless you’re doing something new.

    View full-size slide

  53. Often it’s code
    you inherited!

    View full-size slide

  54. Managing a Codebase

    View full-size slide

  55. Managing a Community

    View full-size slide

  56. Be inclusive.

    View full-size slide

  57. Prefer face to face.

    View full-size slide

  58. flic.kr/jeremylevinedesign
    flic.kr/koreanet

    View full-size slide

  59. • Be responsive.
    • Engage with people.
    • Say no (nicely).
    • Cut releases.
    Responsibilities

    View full-size slide

  60. • Guide the ship.
    • Programming is fun.
    • Make friends!
    • Reputation.

    (which you can exchange for speaking opportunities at Droidcons)
    Perks

    View full-size slide

  61. Enjoy Droidcon Montréal
    @jakewharton @jessewilson

    View full-size slide