Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
秩序あるKotlinの拡張 / Orderly Kotlin Extensions
Masatoshi Kubode
June 23, 2021
Programming
0
810
秩序あるKotlinの拡張 / Orderly Kotlin Extensions
https://potatotips.connpass.com/event/214754/
Masatoshi Kubode
June 23, 2021
Tweet
Share
More Decks by Masatoshi Kubode
See All by Masatoshi Kubode
GraphQL+KMM開発でわかったこと / What we learned from GraphQL+KMM development
kubode
0
120
Coroutines 1.6移行記録 / Tried to migrate Coroutines to 1.6
kubode
1
110
KMMでプラットフォーム依存を抑える設計 / A KMM architecture reducing the platform dependency
kubode
0
490
KMMを使って感じたPros/Cons / Pros/Cons experienced using KMM
kubode
1
1k
KMMのテストのtips / KMM testing tips
kubode
1
220
KMMの導入と得られるもの / Introduction of KMM and its benefits
kubode
2
1.1k
The Pitfalls of Cancellation
kubode
0
1.2k
Room 2.2.0-alpha01
kubode
1
1.4k
Multi-module+Navigation
kubode
0
580
Other Decks in Programming
See All in Programming
SRE NEXT 2022: Sensible Incident Management for Software Startups
takanabe
2
280
コードの解析と言語習得の心得
jinjin33333
0
130
TSDサービスRecap ~PMBOK®ガイド第7版超速まるわかりガイド~|ミツエーリンクスTSD
mlctsd
0
100
もしも、 上司に鬼退治を命じられたら~プロジェクト計画編~
higuuu
0
270
脱オブジェクト指向講座(5分LT資料)
kishida
8
11k
スモールチームがAmazon Cognitoでコスパよく作るサービス間連携認証
tacke_jp
2
350
Better Reliability through Observability (and Experimentation)
ksatirli
PRO
1
230
書籍『良いコード/悪いコードで学ぶ設計入門』でエンジニアリングの当たり前を変える
minodriven
3
1.1k
偏見と妄想で語るスクリプト言語としての Swift / Swift as a Scripting Language
lovee
2
260
【Qiita Night】新卒エンジニアによるSwift6与太予想
eiji127
0
180
Android入門
hn410
0
310
Microsoft Teams の 会議アプリ開発のはじめかた / How to start Microsoft Teams app development
karamem0
0
1.6k
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
12
890
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
Navigating Team Friction
lara
175
11k
VelocityConf: Rendering Performance Case Studies
addyosmani
316
22k
The Brand Is Dead. Long Live the Brand.
mthomps
45
2.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
19
1.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
3
440
Art, The Web, and Tiny UX
lynnandtonic
280
17k
Six Lessons from altMBA
skipperchong
14
1.3k
Facilitating Awesome Meetings
lara
29
3.9k
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.1k
In The Pink: A Labor of Love
frogandcode
130
21k
Transcript
©2021 Wantedly, Inc. டং͋ΔKotlinͷ֦ு potatotips #74 2021/06/23 ٱอग़խढ़
©2021 Wantedly, Inc. XXXXBOUFEMZDPNJELVCPEF
©2021 Wantedly, Inc. w JOUFSGBDFͱPCKFDU֦ுؔͰɺ֦ுʹடং ΛͨͤΔ 5-%3
©2021 Wantedly, Inc. ܦҢ
©2021 Wantedly, Inc. w ,..ʹ(SBQI2-Λಋೖ ܦҢ
©2021 Wantedly, Inc. w 3FQPTJUPSZͰϑΣονͨ͠σʔλΛอଘ͍ͨ͠ Γ͍ͨ͜ͱ อଘͨ͠Β GetUseCaseʹ ௨͞ΕΔ
©2021 Wantedly, Inc. w ෳͷGSBHNFOUΛ͏·͘อଘ͍ͨ͠ fragmentͱ • σʔλϞσϧΛஅยԽͨ͠ͷ • ಉ͡ϞσϧΛࢦ͕͢ใྔ͕ҧ͏
• ҰཡͰ࠷খݶ • ৄࡉͰ࠷େݶ Ϟσϧಉ͡ͳͷͰɺ ಉ͡ςʔϒϧʹอଘ͍ͨ͠ Γ͍ͨ͜ͱ fragment ProfileMini on Profile { userId name avatarUrl } fragment ProfileDetail on Profile { userId name avatarUrl coverImageUrl introduction tagline statement # ... all fields }
©2021 Wantedly, Inc. w ECNFSHF GSBHNFOU Έ͍ͨʹॻ͖͍ͨ w 42-%FMJHIUʹࠩΛٵऩͯ͠ɺ͍͍ײ͡ʹอଘ ͢Δػೳͳ͍
Γ͍ͨ͜ͱ
©2021 Wantedly, Inc. w ୯७ʹ֦ுΛॻ͍ͨ Ͳ͏͔ͨ͠ʁ fun Db.merge(fragment: ProfileMiniFragment) {
profilePageQueries.upsertMiniFragment( userId = UserId(fragment.userId), // ... ) }
©2021 Wantedly, Inc. fun Db.merge(fragment: ProfileMiniFragment) { profilePageQueries.upsertMiniFragment( userId
= UserId(fragment.userId), // ... ) } ໊લʹറΓ͕ͳ͍ɺ໎͏ mergeDetail, saveͱ͔ϒϨ͍͢ ҾʹറΓ͕ͳ͍ interfaceͰ੍Λ͍࣋ͨͤͨʂ
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2021 Wantedly, Inc. JOUFSGBDF PCKFDU֦ுؔ
©2021 Wantedly, Inc. PCKFDU֦ுؔ object Foo { fun String.hello() {
println("Hello, $this") } } objectʹ֦ுؔΛ࡞Δ ී௨ͷ֦ுؔͷΑ͏ʹར༻Ͱ͖Δ import Foo.hello fun main() { "World".hello() }
©2021 Wantedly, Inc. ղܾख๏ internal interface Merger<FragmentT> { fun Db.merge(fragment:
FragmentT) } internal object ProfileMiniFragmentMerger : Merger<ProfileMiniFragment> { override fun Db.merge(fragment: ProfileMiniFragment) { profilePageQueries.upsertFragment( userId = UserId(fragment.userId), // ... ) } } // Repository fun fetchMiniList() { val miniList = api.query(GetProfileMiniListQuery()) db.transaction { miniList.forEach { db.merge(it) } } } internal object ProfileDetailFragmentMerger : Merger<ProfileDetailFragment> { override fun Db.merge(fragment: ProfileDetailFragment) { profilePageQueries.upsertFragment( userId = UserId(fragment.userId), // ... ) } } // Repository fun fetchDetail() { val detail = api.query(GetProfileDetailQuery()) db.merge(detail) } ֦ுؔΛ࣋ͭ object࣮ object֦ுؔΛݺΜͰ͍Δ
©2021 Wantedly, Inc. w JOUFSGBDFͱPCKFDU֦ுؔͰɺ֦ுʹடংΛ ͨͤΔ͜ͱ͕Ͱ͖Δ w ࠜຊతʹίʔυੜͱ͔ͰϘΠϥʔϓϨʔτΛ ݮΒ͖͢ʜ ·ͱΊ
ϖʔδλΠτϧ ϖʔδαϒλΠτϧ ©2021 Wantedly, Inc. 🙇