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
Kotlin学習とライブラリ作成
Search
yagi
March 24, 2016
Technology
1
4.2k
Kotlin学習とライブラリ作成
ライブラリ作成をしながらKotlinを学習するといいんじゃないかなーという話です
yagi
March 24, 2016
Tweet
Share
More Decks by yagi
See All by yagi
医療現場の解像度を上げるために 開発チームが行っている取り組み
sys1yagi
0
670
これどうやって動いてるんだ? Spring Framework/Bootのソースを読む
sys1yagi
1
1.2k
Kotlin コルーチンを 理解しよう 2019 - KotlinFest2019 -
sys1yagi
40
30k
5分でわかるKotlin Coroutines Flow
sys1yagi
21
18k
Androidと非同期処理 とCoroutine1.0.0
sys1yagi
12
13k
Kotlin コルーチンを 理解しよう
sys1yagi
41
24k
アーキテクチャと Scaffolding Template
sys1yagi
8
1.3k
Androidの非同期処理をKotlinコルーチンで行う
sys1yagi
3
23k
解剖Kotlin ~バイトコードを読み解く~
sys1yagi
18
9.9k
Other Decks in Technology
See All in Technology
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
170
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
110
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
15
12k
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
MLOps の現場から
asei
6
650
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
270
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
2
380
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
Wantedly での Datadog 活用事例
bgpat
1
490
ハイテク休憩
sat
PRO
2
160
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
33
1.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
What's in a price? How to price your products and services
michaelherold
243
12k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Fireside Chat
paigeccino
34
3.1k
Mobile First: as difficult as doing things right
swwweet
222
9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
A Philosophy of Restraint
colly
203
16k
How STYLIGHT went responsive
nonsquared
95
5.2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Transcript
,PUMJOֶशͱϥΠϒϥϦ࡞ 2016 03 24 @ Sansan Toshihiro Yagi
About Me Toshihiro Yagi Twitter : sys1yagi Programmer at Cookpad
Inc. Android engineer Kotlin2014ॳ಄ลΓ͔ΒŧŔŕŪ৮͍ͬͯΔఔ
Target & Agenda ,PUMJOֶशͷͨΊʹϥΠϒϥϦ࡞ͬͯΈΔͷ݁ ߏ͍͍Μ͡Όͳ͍͔ͳʔͱ͍͏Ͱ͢ɻ LNPDLJUPͱ͍͏ϥΠϒϥϦͱڞʹ࡞࣌ʹͬ ͨ,PUMJOͷػೳͳͲΛհ͠·͢ɻ ,PUMJOͷجຊతͳݴޠͷػೳ͍ͬͯͯ,PUMJO Λͬͯ۩ମతʹͲ͏͍ͬͨࣄ͕Ͱ͖ͦ͏͔ͳ͊ʔ ͱߟ͍͑ͯΔਓ͚
What is kmockito?
Wrapper of Mockito for Kotlin NPDL WBSJUFN*UFNNPDL XIFO JUFNMFOHUI
JOWPLFEUIFO3FUVSO BOTXFS JUFNTPNF.FUIPE BOZ*OU BOZ4USJOH BOZ BOZ JOWPLFE UIFO"OTXFS\ WBM B C D E JUBSHVNFOUT*OU 4USJOH *UFN /BNF EPTPNFUIJOH ^ WFSJGZ JUFNWFSJGZ UJNFT MFOHUI https://github.com/sys1yagi/kmockito
Motivation
bXIFO`,PUMJOͷ༧ޠ WBMJUFNNPDL *UFNDMBTTKBWB AXIFOA JUFNMFOHUI UIFO3FUVSO ༧ޠͱඃΒͳ͍Α͏ʹΤεέʔϓ͕ඞཁ
BOZ ͕OVMMΛฦ͢ AXIFOA JUFNMFOHUI BOZ UIFO3FUVSO ʜ any() return null
and cause runtime error GVOMFOHUI UFYU4USJOH *OU\ʜ^ Non-Null
Yes kmockito!
Using features of Kotlin top-level extensions inline and reified Extension
Properties Destructuring Declarations
top-level extensions
τοϓϨϕϧʹ͕ؔॻ͚ͯศར
TUBUJDϝιου܈Λ࣋ͭΫϥε͕ੜ͞ΕΔ ֦ுؔ܈XX_extension.ktʹूΊΔͱΑͦ͞͏
lnline & reified
ͳܕͷهड़ΛΊΔ WBMJUFNNPDL *UFNDMBTTKBWB WBMJUFN*UFNNPDL JUFNMFOHUI NPDL
ͳܕͷهड़ΛΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB
ͳܕͷهड़ΛΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ
ͳܕͷهड़ΛΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB
ͳܕͷهड़ΛΊΔ GVO5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB ܕফڈʹΑͬͯΤϥʔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB JOMJOFԽͯ͠ܕύϥϝʔλʹSFJpFEΛ༩͢Δͱ5Λ۩ܕͱ͔ͯ͋ͭ͑͠Δ ˞LPUMJOSFqFDU͕ඞཁͰ͢
ͳܕͷهड़ΛΊΔ JOMJOFGVOSFJpFE5"OZNPDL .PDLJUPNPDL 5DMBTTKBWB WBMJUFN*UFNNPDL JUFNMFOHUI NPDL :FT
Extension Properties
ͳϝιουݺͼग़͠ΛΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT JUFNMFOHUI JOWPLFE UIFO3FUVSO
ͳϝιουݺͼग़͠ΛΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT JUFNMFOHUI JOWPLFE UIFO3FUVSO ͳͯ͘Α͘ͳ͍ʁ
ͳϝιουݺͼग़͠ΛΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT WBM55JOWPLFE0OHPJOH4UVCCJOH5 HFU JOWPLFE ɾ&YUFOTJPO1SPQFSUJFTͰҙͷΫϥεʹϓϩύςΟΛ༩͢Δ ɾϓϩύςΟΞΫηε࣌ʹϝιουݺͼग़͠
ͳϝιουݺͼग़͠ΛΊΔ GVO55JOWPLFE .PDLJUPAXIFOA UIJT WBM55JOWPLFE0OHPJOH4UVCCJOH5 HFU JOWPLFE ɾ&YUFOTJPO1SPQFSUJFTͰҙͷΫϥεʹϓϩύςΟΛ༩͢Δ ɾϓϩύςΟΞΫηε࣌ʹϝιουݺͼग़͠
JUFNMFOHUI JOWPLFEUIFO3FUVSO
Destructuring Declarations
85' JUFNTPNF.FUIPE BOZ*OU BOZ4USJOH BOZ BOZ JOWPLFE UIFO"OTXFS\ WBMBJUBSHVNFOUT<>BT*OU
WBMCJUBSHVNFOUT<>BT4USJOH WBMDJUBSHVNFOUT<>BT*UFN WBMEJUBSHVNFOUT<>BT/BNF EPTPNFUIJOH ^
%FTUSVDUVSJOH%FDMBSBUJPOT Λͬͨೖ WBM B C 1BJS l)FMMPz Bl)FMMPz
C
%FTUSVDUVSJOH%FDMBSBUJPOT Λͬͨೖ WBM B C 1BJS l)FMMPz Bl)FMMPz
C ಛఆͷϧʔϧʹԊͬͨΫϥεͰ %FTUSVDUVSJOH%FDMBSBUJPOT͕͑Δɻ
%FTUSVDUVSJOH%FDMBSBUJPOTͷϧʔϧ DMBTT'PP\ PQFSBUPSGVODPNQPOFOU 4USJOHʜ PQFSBUPSGVODPNQPOFOU *OUʜ PQFSBUPSGVODPNQPOFOU/ 5ʜ ^ GVOEP4PNFUIJOH
GPP'PP \ WBM B C GPP ʜ ^ DPNQPOFOU/ ͱ͍͏ϝιουΛඞཁͳ͚ͩ࣋ͭ
%BUB$MBTTͰએݴָʑ EBUBDMBTT'PP WBMB4USJOH WBMC*OU GVOEP4PNFUIJOH GPP'PP \ WBM B C
GPP ʜ ^ %BUB$MBTTͰলུՄೳ
*OWPDBUJPO0O.PDLʹϝιουΛՃ JOMJOFGVOSFJpFE" SFJpFE# SFJpFE$ *OWPDBUJPO0O.PDLBSHVNFOUT 5SJQMF BSHVNFOUT<>BT" BSHVNFOUT<>BT# BSHVNFOUT<>BT$
*OWPDBUJPO0O.PDLʹϝιουΛՃ JOMJOFGVOSFJpFE" SFJpFE# SFJpFE$ *OWPDBUJPO0O.PDLBSHVNFOUT 5SJQMF BSHVNFOUT<>BT" BSHVNFOUT<>BT# BSHVNFOUT<>BT$
JUFNTPNF.FUIPE BOZ*OU BOZ4USJOH BOZ JOWPLFE UIFO"OTXFS\ WBM B C D JUBSHVNFOUT*OU 4USJOH *UFN EPTPNFUIJOH ^ :FT
Conclusion
,PUMJOֶशͱϥΠϒϥϦ࡞ ߦఔͰ݁ߏ͑Δͷ͕࡞ΕΔ ϥΠϒϥϦͩͱ"OESPJEͳͲͷϑϨʔϜϫʔΫ ʹ͋·ΓറΒΕͣॻ͚ΔͷͰֶश͕͔ͲΔ େମίʔυ͕ճ͘Β͍ม͢ΔɻͦͷதͰ,PUMJO ͷ༷ػೳॻ͖ํͳͲʹ͍ͭͯ৭ʑͱ۷ΕΔ ࠷ѱࣺͯΒΕΔ
Let’s Enjoy Kotlin life ϥΠϒϥϦΛ࡞ͬͯ
͓·͚
ಉ͡Α͏ͳϥΠϒϥϦཚཱ ͏ʔΜͲ͏ͨ͠ͷ͔
"XFTPNFLPUMJO ͜͜ʹೖΓ͍ͨ https://github.com/JavaBy/awesome-kotlin
ؤுΖ͏