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
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Developing an Android library
Slides from my barcamp talk at Droidcon Vienna 2016.
Dino Kovač
September 17, 2016
More Decks by Dino Kovač
See All by Dino Kovač
Continuous integration and deployment on Android (plus some sweets)
reisub
1
620
Kickstart your Android development
reisub
1
82
Continuous integration and deployment on Android
reisub
0
230
Other Decks in Programming
See All in Programming
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
490
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
140
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
120
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.8k
yield再入門 #phpcon
o0h
PRO
0
380
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
130
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4.3k
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
520
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
6.1k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
850
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
Embracing the Ebb and Flow
colly
88
5.1k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Believing is Seeing
oripsolob
1
170
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
390
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
The Pragmatic Product Professional
lauravandoore
37
7.4k
A designer walks into a library…
pauljervisheath
211
24k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
310
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
How to train your dragon (web standard)
notwaldorf
97
6.7k
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?
[email protected]
@DINO_BLACKSMITH Visit infinum.co or find us on
social networks: infinum.co infinumco infinumco infinum