Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
10-ish Things about Android Library Development
Search
Zan Markan
May 09, 2017
Programming
0
98
10-ish Things about Android Library Development
Talk given at Droidcon London Bytes meetup
Zan Markan
May 09, 2017
Tweet
Share
More Decks by Zan Markan
See All by Zan Markan
High-Performing Engineering Teams and the Holy Grail
zmarkan
0
72
A Practical Introduction to CI/CD
zmarkan
0
31
The Need for Speed - Practical Tips for Optimising your CI/CD Pipeline
zmarkan
0
57
Chat app with React, Auth0, and Pusher Chatkit
zmarkan
0
310
State of Kotlin - Droidcon NYC
zmarkan
1
65
State of Kotlin - Droidcon Berlin 2018
zmarkan
1
140
Building DSLs in Kotlin for Fun and Profit
zmarkan
2
510
Push Notifications That Don't Suck
zmarkan
3
380
The State of Kotlin
zmarkan
0
180
Other Decks in Programming
See All in Programming
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
280
Recoilを剥がしている話
kirik
5
6.7k
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
380
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
260
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
Go の GC の不得意な部分を克服したい
taiyow
3
780
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Mobile First: as difficult as doing things right
swwweet
222
9k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Building Your Own Lightsaber
phodgson
103
6.1k
Transcript
@zmarkan Zan Markan @zmarkan LIBRARY DEVELOPMENT 10-ish things about Android
@zmarkan @zmarkan Developer tools company blog.pusher.com Chat API Hiring in
Shoreditch Trusted by 150k+ devs pusher.com | @pusher
@zmarkan Contents of this talk • Libs 101 • API
Design • Development & Testing • Releasing • Docs ...and more!
@zmarkan We libs because... Avoid duplicating logic - Best Practice
Sharing == Caring It’s a great way to enrich your We want to be paid
@zmarkan Libraries are a collection of classes and methods that
encapsulate common, shared functionality.
@zmarkan Libs != Apps Libraries are NOT end products Smaller,
more lightweight than apps Many x Many apps/lib ratio
@zmarkan All about that Lib... What: Libraries, Frameworks, SDKs Type:
General libs, UI Widgets, Serverside, Testing Access: Publicly vs Privately accessible Pricing: FOSS, Free to use vs Commercial API: DSL, Reactive, n other things...
@zmarkan Product is about the User • Developers (like you
and I) • Varied backgrounds, levels of experience • User experience -> Developer experience
@zmarkan the truth about developers Library users are Developers… …
developers are very lazy, so... libraries should enable laziness.
@zmarkan API
@zmarkan The API is to a library what the USER
INTERFACE is to an APP
@zmarkan Things I mean by API Entry points Interaction points
Data model Errors & Exceptions
@zmarkan Entry points (where people first interact with your code)
They allow you to instantiate and configure the library In “Code”: Constructors, Builders, Factories In UI: Widgets
@zmarkan Builder Poor person’s named args … and optional args
Ensures constructor is passed correct values, and validates its state before building the class
@zmarkan Building the - Static inner class - … called
Builder - setters mutate its state, returning this - build() constructs the main object - build() validates the view state AS SEEN IN RETROFIT
@zmarkan Methods & Models When in doubt - go S.O.L.I.D.
Naming, Naming, Naming! Don’t surprise your users! (But you can delight them)
@zmarkan (R)X-Factor Aysnc as a stream of events Allows chaining,
and functional operations Support all the things: RxSwift, RxJava (even PHP!) More: Paco Estevez makes AWESOME Rx libs/articles/talks
@zmarkan RX in brief observable .filter(//condition) .flatMap(//transformation) .subscribe(//handleSuccess, //handleError) Not
shown: one million operators, threading, ...
@zmarkan RX… but It’s still a power user feature Callbacks
are still often preferred provide RX adapter as an optional extra?
@zmarkan for the λ Consider functional interfaces ...they can be
replaced with lambdas easily Used with Retrolambda, Kotlin, Java 8 Power users tend to like them. Be nice to your power users.
@zmarkan @nnotations Add validation features - NotNull, Nullable Value types
- AutoValue, AutoParcel Build Annotations to write code for you Use Square/JavaPoet More: Jason Feinstein’s talk from CodeMotion Tel Aviv 2016
@zmarkan DSL-o-Matic 9000 Make your own little programming language… ...by
inventing a syntax that works for you! Examples: Hamcrest, Rx, Kotlin Anko Techniques: Annotations, Operator overloading, Extension methods, ...
@zmarkan When things go • Let it crash! • Early
• Often Ensure the error messaging is spot on Add links in error messages to explanations
@zmarkan Anatomy of a “nice” Error Type: Illegal Input Message:
Request unsuccessful, reason: malformed auth token Link: https://example.com/errors/123456 Explain things here!
@zmarkan DEV & TEST
@zmarkan Performance or Be wary of: • Library size =>
App size • Memory leaks • Build times • Needless dependencies
@zmarkan ...my lib ain’t one! - Avoid private fields in
parent classes - Prefer anonymous inner classes to lambdas - Avoid needless dependencies (again) - Proguard rules More: Jake Wharton’s talk from 360AnDev I got 65k problems, but...
@zmarkan API should be beautiful. Implementation should f*****g work.
@zmarkan Testing it & Loving it The easy: Unit Tests
The hard: Integration Tests with an app The smart: fooding More in: David Schreiber-Ranner’s talk from Droidcon Vienna 2016
@zmarkan Tracking & Analysis Problem: No Google Analytics for libraries
Track at the service level? Listen and talk to users fooding: Redux unless you’re Fabric
@zmarkan
@zmarkan (Semantic) Versioning 2.0 Major[.]Minor[.]Patch • Major: Breaking changes •
Minor: New features • Patch: Hotfixes Shouldn’t ever happen • semver.org
@zmarkan Releasing (how not to do it) • Manually include
the JAR/AAR in your project (Bad idea in most cases) • Include project as a Git submodule (Even worse idea in all cases)
@zmarkan Releasing (the right way) Maven Central JCenter Jitpack Artifactory
Maven dir on S3 Managed services free for OSS More DIY just add server
@zmarkan DOCS
@zmarkan 50 shades of Docs • Quick Start • Sample
apps • JavaDoc • Wiki pages • Yes, even tests! • Mix & Match!
@zmarkan Quickstart a.k.a. “Let me copypaste something”
@zmarkan Sample code • Should be small, confined apps •
… often alongside libraries in the same repo • Should reflect your libraries’ features • Can go in-depth for more advanced features
@zmarkan JavaDoc • Cheap to make • Automagically generated •
(Just add comments!) • Great in Android Studio • Host it alongside your other docs
@zmarkan Libraries enable app developers to be lazy. Docs enable
library developers to be lazy.
@zmarkan The takeaways Libs 101 API design Development Releasing Support
@zmarkan @zmarkan fin Blog: www.spacecowboyrocketcompany.com Twitter: @zmarkan Github: @zmarkan Email:
zan@[pusher.com | markan.me]