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
Developing an Android library
Search
Dino Kovač
September 17, 2016
Programming
0
130
Developing an Android library
Slides from my barcamp talk at Droidcon Vienna 2016.
Dino Kovač
September 17, 2016
Tweet
Share
More Decks by Dino Kovač
See All by Dino Kovač
Continuous integration and deployment on Android (plus some sweets)
reisub
1
550
Kickstart your Android development
reisub
1
76
Continuous integration and deployment on Android
reisub
0
220
Other Decks in Programming
See All in Programming
私のRubyKaigi 2025 Kaigi Effect / My RubyKaigi 2025 Kaigi Effect
chobishiba
1
110
AIコーディングの本質は“コード“ではなく“構造“だった / The essence of AI coding is not “code” but "structure
seike460
PRO
2
410
VitestのIn-Source Testingが便利
taro28
9
2.4k
ニーリーQAのこれまでとこれから
nealle
2
810
インプロセスQAにおいて大事にしていること / In-process QA Meetup
medley
0
170
Road to Ruby for A Linguistics Nerd
hayat01sh1da
PRO
0
240
AIコーディングエージェントを 「使いこなす」ための実践知と現在地 in ログラス / How to Use AI Coding Agent in Loglass
rkaga
4
1.4k
ComposeでのPicture in Picture
takathemax
0
140
eBPF超入門「o11yに使える」とは (20250424_eBPF_o11y)
thousanda
1
120
「理解」を重視したAI活用開発
fast_doctor
0
300
REALITY コマンド作成チュートリアル
nishiuriraku
0
120
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
6
1.6k
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
41
2.3k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Automating Front-end Workflow
addyosmani
1370
200k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
The Invisible Side of Design
smashingmag
299
50k
Agile that works and the tools we love
rasmusluckow
329
21k
Transcript
Developing an Android library DINO KOVAČ
01 WHY?
WHY A LIBRARY? • DRY - don’t repeat yourself •
easier than copy/pasting classes
WHY AN OPEN SOURCE LIBRARY? • saving others time •
useful contributions from community • eternal fame!
02 WHAT?
DOES IT MAKES SENSE TO BUILD IT? • is there
a real need? • any existing libraries?
PICK A GOOD NAME • one that doesn’t already exist
• should make sense • bonus points if it’s amusing • example: • HTTParty - Makes http fun again!
03 HOW?
MIND THE API • primary way users interact with your
lib • make it easy to use • make it robust (avoid footguns!)
None
HTTPURLCONNECTION HttpURLConnection urlConnection = null; try { URL url =
new URL("https://api.github.com/markdown/raw"); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setChunkedStreamingMode(0); OutputStream out = new BufferedOutputStream(connection.getOutputStream()); writeStream(out); InputStream in = new BufferedInputStream(connection.getInputStream()); readStream(in); } catch (IOException e) { // handle this } finally { if (connection != null) { connection.disconnect(); } }
HTTPURLCONNECTION
OKHTTP Request request = new Request.Builder() .url("https://api.github.com/markdown/raw") .post(RequestBody.create(MediaType.parse("text/plain"), "post body"))
.build(); try { Response response = client.newCall(request).execute(); } catch (IOException e) { // handle this }
FAIL FAST • as much validation as reasonably possible •
fail as fast as possible
FAIL FAST public Builder post(RequestBody body) { return method("POST", body);
} public Builder method(String method, RequestBody body) { if (method == null || method.length() == 0) { throw new IllegalArgumentException("method == null || method.length() == 0"); } if (body != null && !HttpMethod.permitsRequestBody(method)) { throw new IllegalArgumentException("method " + method + " must not have a request body."); } if (body == null && HttpMethod.requiresRequestBody(method)) { throw new IllegalArgumentException("method " + method + " must have a request body."); } this.method = method; this.body = body; return this; }
DON’T EXPOSE THE INTERNALS • package-protected classes • private or
protected methods
APP RESOURCES LIBRARY RESOURCES MERGED RESOURCES
APP RESOURCES LIBRARY RESOURCES MERGED RESOURCES @string/app_name @string/app_name @string/app_name
APP RESOURCES LIBRARY RESOURCES MERGED RESOURCES @string/app_name (en) @string/app_name (fr)
@string/app_name (de) @string/app_name (en) @string/app_name (fr) @string/app_name (de) @string/app_name
ANDROID SPECIFICS • build.gradle • resourcePrefix 'dbinspector_'
WRITE THE DOCS • what does it do? • how
do I use it? • maybe an example app?
DISTRIBUTE • don’t use maven central, use jcenter • automate
deployment
SHAMELESS SELF-PROMOTION • https://github.com/infinum/android_dbinspector • https://github.com/reisub/HttPizza
Any questions? DINO@INFINUM.CO @DINO_BLACKSMITH Visit infinum.co or find us on
social networks: infinum.co infinumco infinumco infinum