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
580
Kickstart your Android development
reisub
1
78
Continuous integration and deployment on Android
reisub
0
220
Other Decks in Programming
See All in Programming
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1k
Leading Effective Engineering Teams in the AI Era
addyosmani
2
310
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
130
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
180
TFLintカスタムプラグインで始める Terraformコード品質管理
bells17
2
160
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
520
Cloudflare AgentsとAI SDKでAIエージェントを作ってみた
briete
0
140
XP, Testing and ninja testing ZOZ5
m_seki
3
620
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
820
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
400
高度なUI/UXこそHotwireで作ろう Kaigi on Rails 2025
naofumi
4
4k
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
480
Featured
See All Featured
Done Done
chrislema
185
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
870
Designing for humans not robots
tammielis
254
26k
A Tale of Four Properties
chriscoyier
161
23k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Site-Speed That Sticks
csswizardry
11
900
Scaling GitHub
holman
463
140k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
970
RailsConf 2023
tenderlove
30
1.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
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