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
Null the abyss
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Keishin Yokomaku
May 13, 2015
Technology
3.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Null the abyss
We need to look after 'null' value carefully.
Keishin Yokomaku
May 13, 2015
More Decks by Keishin Yokomaku
See All by Keishin Yokomaku
Base64 in Android
keithyokoma
0
52
One screen, many BottomSheets
keithyokoma
0
460
LazyColumnのitemがViewPortの中で占める領域の割合を知りたい
keithyokoma
0
750
Build apps for Cars
keithyokoma
0
580
Save the state
keithyokoma
0
620
Either in Kotlin
keithyokoma
0
640
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
5.6k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
5.3k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
590
Other Decks in Technology
See All in Technology
AI Engineering Summit Tokyo 2026 AIの前に、やることがある 〜医療データ企業の4フェーズ〜
dtaniwaki
0
2k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
510
個人の発見を、組織の知恵に 〜生成AI活用を"探索"から"組織の仕組み"へ〜
kintotechdev
2
1k
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
210
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
570
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
360
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1.2k
Building applications in the Gemini API family.
line_developers_tw
PRO
0
1.9k
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
260
そのPoC、何を検証したつもりでしたか? AIプロダクトの価値検証で陥った落とし穴
techtekt
PRO
0
150
AWSシリコン最前線 〜AI時代のチップ選択を読み解く〜
htokoyo
1
160
Featured
See All Featured
Leo the Paperboy
mayatellez
7
1.8k
The browser strikes back
jonoalderson
0
1.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
It's Worth the Effort
3n
188
29k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
220
Prompt Engineering for Job Search
mfonobong
0
330
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
360
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Transcript
Null, the Abyss @KeithYokoma - Drivemode, Inc. potatotips #17
KeithYokoma Keishin Yokomaku Drivemode, Inc. Android Engineer GitHub: https://github.com/KeithYokoma Qiita:
http://qiita.com/KeithYokoma e-Book: http://amzn.to/1mZNydv
None
˒ˑˑˑˑ
None
None
˒ˑˑˑˑ ˒ˑˑˑˑ ˒ˑˑˑˑ
–Someone “A lot of sadness is coming from NullPointerException”
Avoid NullPointerException • Null check for nullable value • Using
support annotation • Using NullObject pattern • Returning null value • Null abyss in Android
Null check statement public void method(Object arg) { if (arg
== null) { throw new NullPointerException(); } // … }
Null check statement public void method(Object arg) { if (arg
== null) { throw new NullPointerException(); } // … }
Null check statement ✓ Easy and basic way to avoid
NPE ✗ Too many checks is bad for performance ✗ Need documentation for nullity ✗ Failure at runtime
Support Annotations public void method(@Nullable Object arg) { if (arg
== null) { Log.w(“Logger”, “Nothing I can do.”) return; } // … }
Support Annotations public void method(@Nullable Object arg) { if (arg
== null) { Log.w(“Logger”, “Nothing I can do.”) return; } // … }
Support Annotations ✓ Gain Lint support for nullity ✓ Users
can understand about nullity ✗ Still have possibility of null value ✗ Failure at runtime
Using NullObject pattern ✓ No possibility of null value ✓
No change to get NullPointerException ✗ Need to learn architecture
Using NullObject pattern Bad Practice public enum NavMenu { HOME(R.id.home),
PROFILE(R.id.profile); public static NavMenu get(int id) { for (NavMenu menu : values()) { if (menu.id == id) return menu; } return null; } }
Using NullObject pattern Good Practice public enum NavMenu { HOME(R.id.home),
PROFILE(R.id.profile), NONE(-1); public static NavMenu get(int id) { for (NavMenu menu : values()) { if (menu.id == id) return menu; } return NONE; } }
Returning null value Bad Practice public List<Result> get(int count) {
if (something went wrong) { return null; } //… }
Returning null value Good Practice public List<Result> get(int count) {
if (something went wrong) { return new ArrayList<>(); } //… }
Returning null value Other Good Practice public List<Result> get(int count)
{ if (something went wrong) { throw new SomeException(“Request failed for some reason.”); } //… }
Returning null value • “null” means value is absent •
Empty collection instead of null • Failure for throwing Exception
Null abyss in Android • Some support API returns “null”
• e.g. MediaSessionCompat • You need to verify nullity for those APIs…
None
–Someone “When you gaze into null, null gazes into you”
For more details… • Effective Java
Null, the Abyss @KeithYokoma - Drivemode, Inc. potatotips #17