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
Travelling Across Asia - Our Journey from Java ...
Search
Amal Kakaiya
April 23, 2018
Programming
0
31
Travelling Across Asia - Our Journey from Java to Kotlin
Given at Android Makers FR - Paris, 2018
Amal Kakaiya
April 23, 2018
Tweet
Share
More Decks by Amal Kakaiya
See All by Amal Kakaiya
KotlinConf 18 - Learn together. Not the same.
k4kya
0
470
Other Decks in Programming
See All in Programming
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
8
1.9k
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
1.8k
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.1k
Amazon Nova Reelの可能性
hideg
0
200
テストコード書いてみませんか?
onopon
2
340
Alba: Why, How and What's So Interesting
okuramasafumi
0
210
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1k
Package Traits
ikesyo
1
210
Azure AI Foundryのご紹介
qt_luigi
1
190
快速入門可觀測性
blueswen
0
500
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
How to Ace a Technical Interview
jacobian
276
23k
Being A Developer After 40
akosma
89
590k
A Philosophy of Restraint
colly
203
16k
Speed Design
sergeychernyshev
25
740
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
How STYLIGHT went responsive
nonsquared
96
5.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Transcript
TRAVELLING ACROSS ASIA OUR JOURNEY FROM JAVA TO KOTLIN Amal
Kakaiya @K4KYA @DeliverooEng
None
DISCLAIMER: COULD TAKE MORE THAN 20 HOURS
Java Kotlin AutoValue/Lombok Data classes Streams support Standard lib functions
Retrolambda Built in lambda support Butterknife Kotterknife/delegate properties # TravellingAcrossAsia @K4KYA
ADOPTING A NEW LANGUAGE IS A HUGE STEP # TravellingAcrossAsia
@K4KYA
TESTS ARE AN EASY WAY TO GET STARTED # TravellingAcrossAsia
@K4KYA
TESTS ARE AN EASY WAY TO GET STARTED BUT NOT
VERY EXCITING # TravellingAcrossAsia @K4KYA
HOW MUCH COULD WE IMPROVE THE MAIN APP? # TravellingAcrossAsia
@K4KYA
None
DON’T GO ROGUE! # TravellingAcrossAsia @K4KYA
KOTLIN HOUR THE MEETING YOU ACTUALLY WANT TO GO TO
# TravellingAcrossAsia @K4KYA
YOU CAN’T START USING A LANGUAGE WITHOUT EVERYBODY KNOWING IT
# TravellingAcrossAsia @K4KYA
DO WE REALLY WANT TO ADD ANOTHER DEPENDENCY? # TravellingAcrossAsia
@K4KYA
None
# TravellingAcrossAsia @K4KYA
# TravellingAcrossAsia @K4KYA
FIND YOUR OWN PACE # TravellingAcrossAsia @K4KYA
None
CONVERT ALL THE THINGS!! # TravellingAcrossAsia @K4KYA
IT WASN’T A SMOOTH RIDE # TravellingAcrossAsia @K4KYA
LEARN FROM EACH OTHER # TravellingAcrossAsia @K4KYA
WE REVIEW CODE EVERY DAY # TravellingAcrossAsia @K4KYA
# TravellingAcrossAsia @K4KYA
ANDROID STUDIO IS YOUR FRIEND # TravellingAcrossAsia @K4KYA
private fun mapToIds(items: List<Item>): List<String> { val ids = mutableListOf<String>()
for (item in items) { ids.add(item.id) } return ids } # TravellingAcrossAsia @K4KYA
private fun mapToIds(items: List<Item>): List<String> { val ids = items.map
{ it.id } return ids } # TravellingAcrossAsia @K4KYA
private fun mapToIds(items: List<Item>): List<String> { return items.map { it.id
} } # TravellingAcrossAsia @K4KYA
private fun mapToIds(items: List<Item>): List<String> = items.map { it.id }
# TravellingAcrossAsia @K4KYA
WHAT’S THIS CODE DOING? # TravellingAcrossAsia @K4KYA
private final mapToId(Ljava/util/List;)Ljava/ util/List; L0 LINENUMBER 2 L0 ALOAD 1
CHECKCAST java/lang/Iterable ASTORE 2 ———————— 75 more lines ———————— # TravellingAcrossAsia @K4KYA
private final List mapToId(List items) { Iterable $receiver$iv = (Iterable)items;
Collection destination$iv$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$ iv, 10))); Iterator var5 = $receiver$iv.iterator(); while(var5.hasNext()) { Object item$iv$iv = var5.next(); Item it = (Item)item$iv$iv; String var12 = it.id; destination$iv$iv.add(var12); } return (List)destination$iv$iv; } # TravellingAcrossAsia @K4KYA
EXPECT THE UNEXPECTED # TravellingAcrossAsia @K4KYA
val extraOptions = items .map { "Item $it" } .takeIf
{ showExtraOptions } # TravellingAcrossAsia @K4KYA
Iterable $receiver$iv = (Iterable)items; Collection $receiver$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$iv, 10)));
Iterator var8 = $receiver$iv.iterator(); while(var8.hasNext()) { Object item$iv$iv = var8.next(); String it = (String)item$iv$iv; String var17 = "Item " + it; $receiver$iv.add(var17); } List var10000 = (List)$receiver$iv; List extraOptions = showExtraOptions ? var10000 : null; # TravellingAcrossAsia @K4KYA
Iterable $receiver$iv = (Iterable)items; Collection $receiver$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$iv, 10)));
Iterator var8 = $receiver$iv.iterator(); while(var8.hasNext()) { Object item$iv$iv = var8.next(); String it = (String)item$iv$iv; String var17 = "Item " + it; $receiver$iv.add(var17); } List var10000 = (List)$receiver$iv; List extraOptions = showExtraOptions ? var10000 : null; # TravellingAcrossAsia @K4KYA
val extraOptions = if (showExtraOptions) items .map { "Item $it"
} else null # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERTING CODE ⌘⌥⇧K Ctrl+Alt+⇧+K # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERTING CODE # TravellingAcrossAsia @K4KYA
CONVERSION CREEP # TravellingAcrossAsia @K4KYA
NULLPOINTEREXCEPTION # TravellingAcrossAsia @K4KYA
NULLPOINTEREXCEPTION # TravellingAcrossAsia @K4KYA
KOTLINNULLPOINTEREXCEPTION # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent? -> login(password()) } # TravellingAcrossAsia @K4KYA
CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener
= TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent? -> login(password()) } # TravellingAcrossAsia @K4KYA
CONVERTING CODE class VerifyActivity: BaseActivity<VerifyPresenter>, VerifyScreen { override val message:
String = getString(R.string.verify_error) # TravellingAcrossAsia @K4KYA
CONVERTING CODE class VerifyActivity: BaseActivity<VerifyPresenter>, VerifyScreen { override val message:
String get() = getString(R.string.verify_error) # TravellingAcrossAsia @K4KYA
USE VERSION CONTROL EFFECTIVELY # TravellingAcrossAsia @K4KYA
USE VERSION CONTROL EFFECTIVELY AND YOUR TEAM WILL ❤ YOU
# TravellingAcrossAsia @K4KYA
VERSION HISTORY # TravellingAcrossAsia @K4KYA
VERSION CONTROL CONVERSION AS ONE COMMIT # TravellingAcrossAsia @K4KYA
VERSION CONTROL MERGE CONVERSIONS QUICKLY # TravellingAcrossAsia @K4KYA
VERSION CONTROL # TravellingAcrossAsia @K4KYA
VERSION CONTROL SHARE WHAT YOU LEARNED # TravellingAcrossAsia @K4KYA
SHARE WHAT YOU LEARNED VERSION CONTROL # TravellingAcrossAsia @K4KYA
SHARE WHAT YOU LEARNED VERSION CONTROL # TravellingAcrossAsia @K4KYA
VERSION CONTROL LEAVE IN RETURN TYPES WHEN IT MAKES SENSE
# TravellingAcrossAsia @K4KYA
VERSION CONTROL private fun showPrompt(confirmed: Boolean) = zip(flipper().confirmDrinkingAgeEnabled(), just(confirmed) {
enabled, confirmed -> enabled && (!confirmed) } # TravellingAcrossAsia @K4KYA
VERSION CONTROL private fun showPrompt(confirmed: Boolean): Observable<Boolean> = zip(flipper().confirmDrinkingAgeEnabled(), just(confirmed)
{ enabled, confirmed -> enabled && (!confirmed) } # TravellingAcrossAsia @K4KYA
# TravellingAcrossAsia @K4KYA
ANDROIDANNOTATIONS AUTOVALUE BUTTERKNIFE LOMBOK DAGGER CUSTOM ANNOTATION PROCESSOR # TravellingAcrossAsia
@K4KYA
KAPT KAY - AY - PEE - TEE # TravellingAcrossAsia
@K4KYA
KAPT VS LOMBOK A TRUE STORY # TravellingAcrossAsia @K4KYA
KAPT VS LOMBOK A TRUE STORY # TravellingAcrossAsia @K4KYA
WHAT WOULD WE CHANGE? # TravellingAcrossAsia @K4KYA
CONVERT UTIL CLASSES EARLY # TravellingAcrossAsia @K4KYA
@file:JvmName(“ViewUtils") @JvmName("showView") fun View.show(visible: Boolean) { visibility = if (visible)
VISIBLE else GONE } # TravellingAcrossAsia @K4KYA
DO WHAT WORKS FOR YOUR TEAM # TravellingAcrossAsia @K4KYA
None
THANK YOU WE’RE HIRING Amal Kakaiya @K4KYA