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
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
220
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
170
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
180
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
110
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
160
.NET 9 のパフォーマンス改善
nenonaninu
0
730
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
アップデート紹介:AWS Data Transfer Terminal
stknohg
PRO
0
180
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
840
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Facilitating Awesome Meetings
lara
50
6.1k
Building an army of robots
kneath
302
44k
4 Signs Your Business is Dying
shpigford
181
21k
Fireside Chat
paigeccino
34
3.1k
The Cult of Friendly URLs
andyhume
78
6.1k
Documentation Writing (for coders)
carmenintech
66
4.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Designing for humans not robots
tammielis
250
25k
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
ؤுΖ͏