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
30
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
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
270
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
130
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
170
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
350
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
良いユニットテストを書こう
mototakatsu
7
2.2k
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
5
1.2k
Featured
See All Featured
Navigating Team Friction
lara
183
15k
For a Future-Friendly Web
brad_frost
175
9.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Fireside Chat
paigeccino
34
3.1k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Designing for humans not robots
tammielis
250
25k
Automating Front-end Workflow
addyosmani
1366
200k
Unsuck your backbone
ammeep
669
57k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Building Applications with DynamoDB
mza
91
6.1k
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