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
630
これどうやって動いてるんだ? Spring Framework/Bootのソースを読む
sys1yagi
1
1.1k
Kotlin コルーチンを 理解しよう 2019 - KotlinFest2019 -
sys1yagi
40
30k
5分でわかるKotlin Coroutines Flow
sys1yagi
21
18k
Androidと非同期処理 とCoroutine1.0.0
sys1yagi
12
13k
Kotlin コルーチンを 理解しよう
sys1yagi
41
23k
アーキテクチャと Scaffolding Template
sys1yagi
8
1.3k
Androidの非同期処理をKotlinコルーチンで行う
sys1yagi
3
23k
解剖Kotlin ~バイトコードを読み解く~
sys1yagi
18
9.8k
Other Decks in Technology
See All in Technology
テストを楽に書きたい
tomorrowkey
1
210
地域DXにおけるGrafana活用事例
wacky
0
190
【インフラエンジニアbooks】30分でわかる「AWS継続的セキュリティ実践ガイド」
hssh2_bin
5
1.7k
Webセキュリティのあるきかた
akiym
32
11k
Deno Deploy で Web Cache API を 使えるようになったので試した知見
toranoana
1
110
WSUSが非推奨に!? Windowsの更新管理を改めて勉強する!
ebibibi
0
330
From LibreOffice to « La Suite » : providing civil servants with Free Software sovereign tools
bluehats
0
100
From naive to advanced RAG: the complete guide
glaforge
0
260
業務ヒアリングと知識の呪い
tamai_63
0
300
入社半年(合計1年)でGoogle Cloud 認定を全冠した秘訣🤫
risatube
1
250
Qdrant を用いた検索改善施策の紹介 / Search Engineering Tech Talk 2024 Summer
visional_engineering_and_design
1
220
tenntennはなんでnewmoにnew社したの? - YAPC::Hakodate 2024
tenntenn
PRO
0
320
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
93
13k
For a Future-Friendly Web
brad_frost
174
9.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Mobile First: as difficult as doing things right
swwweet
222
8.8k
Building Applications with DynamoDB
mza
90
6k
Embracing the Ebb and Flow
colly
84
4.4k
How To Stay Up To Date on Web Technology
chriscoyier
787
250k
A Tale of Four Properties
chriscoyier
156
22k
Adopting Sorbet at Scale
ufuk
73
9k
Web Components: a chance to create the future
zenorocha
310
42k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
KATA
mclloyd
28
13k
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 UIFO3FUV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POFOU/ ͱ͍͏ϝιουΛඞཁͳ͚ͩ࣋ͭ
%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
ؤுΖ͏