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
650
これどうやって動いてるんだ? 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.9k
Other Decks in Technology
See All in Technology
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
300
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
TypeScript、上達の瞬間
sadnessojisan
46
13k
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
180
Taming you application's environments
salaboy
0
180
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
Featured
See All Featured
The Language of Interfaces
destraynor
154
24k
Thoughts on Productivity
jonyablonski
67
4.3k
Facilitating Awesome Meetings
lara
50
6.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Speed Design
sergeychernyshev
24
610
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
The World Runs on Bad Software
bkeepers
PRO
65
11k
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%FDMBSBUJP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 ͏ʔΜͲ͏ͨ͠ͷ͔
"XFTPNFLPUMJO ͜͜ʹೖΓ͍ͨ https://github.com/JavaBy/awesome-kotlin
ؤுΖ͏