Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Kotlin & Modern Libraries
Search
Takuji Nishibayashi
February 24, 2016
Technology
320
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin & Modern Libraries
Takuji Nishibayashi
February 24, 2016
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
compose-hot-reload を試そうとした話
takuji31
0
170
CameraX使ってみた
takuji31
0
320
kotlinx.datetime 使ってみた
takuji31
0
1.1k
HiltのCustom Componentについて
takuji31
0
450
java.timeをAndroidで使う
takuji31
0
220
KSPを使ってコード生成
takuji31
0
500
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
3.3k
kotlinx.serialization
takuji31
0
710
kanmoba-returns-02.pdf
takuji31
0
310
Other Decks in Technology
See All in Technology
行動するAIのためのオントロジー | DevRev — Encraft #26.pdf
dvrv_tknrszk
1
590
Goodbye ShellScript, Hello File-based App
shunsock
0
1.3k
認知負荷を吸収し、プロダクトをまたぐPR Preview基盤の設計事例
taiki45
2
540
2026-09-26 Platform Engineering Kaigi 2026 インフラとアプリの境界線と委譲の設計 / Drawing the Infra and App Line
masasuzu
0
440
DORA_Metrics.pdf
wagnerfusca
1
120
AWS FinOps Agent 結局何が得意なの?
siromi
0
220
【ゲームメーカーズスクランブル2026】『Shadowverse: Worlds Beyond』UIとアニメーションで実現する最高のユーザー体験を叶えるプロトタイピング
cygames
PRO
1
700
いちAWSエンジニアのAI活用を振り返る #devio2026 / devio osaka 2026 kawahara
masahirokawahara
1
260
地方移住と都心キャリアの両立は「金・時間・人」のリソースをフル活用すれば実現できる!〜Snowflake女子会 vol.8
snowwmn0824
0
130
猫でもわかるKiro Web
kentapapa
1
150
個別開発で終わらせない。 現場の課題をプロダクトの強さに変える StockmarkのFDE
ktkrhr
0
350
The kernel report
ennael
PRO
1
130
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
290
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
How to build a perfect <img>
jonoalderson
1
6k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Speed Design
sergeychernyshev
33
2.1k
Become a Pro
speakerdeck
PRO
31
6.3k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
A better future with KSS
kneath
240
18k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
470
A Tale of Four Properties
chriscoyier
163
24k
Transcript
Kotlin & modern libraries @takuji31
@takuji31 (Takuji Nishibayashi) Application Engineer at Hatena
Loves (AVG 160)
Loves Kotlin
Kotlin
Kotlin 1.0.0 released
JVM Language by JetBrains
Like Swift syntax
Like Swift syntax Swift is Kotlin like syntax!
Java Interoperability
Less boilerplate code
Android ready
Pretty name
Kotlin + modern libraries = happy
Dagger2
Provides in module constructor
Java @Module public class AppModule { private final Context context;
public AppModule(Context context) { this.context = context; } @Provides public Context context() { return context; } @Provides public NotificationManager notificationManager(Context context) { return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); } }
Kotlin (Provider methods) @Module class AppModule( val context: Context )
{ @Provides fun context() : Context = context @Provides fun notificationManager(context: Context) : NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }
Use property
Kotlin (Constructor property) @Module class AppModule( @get:Provides val context: Context
) { @Provides fun notificationManager(context: Context) : NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }
Kotlin (Constructor property) @Module class AppModule( @get:Provides val context: Context,
@get:Provides val notificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager ) { }
Provides in component property
Java @Component(modules = AppModule.class) @Singleton public interface AppComponent { Context
context(); NotificationManager notificationManager(); }
Kotlin (functions) @Singleton @Component(modules = arrayOf(AppModule::class)) interface AppComponent { fun
context(): Context fun notificationManager(): NotificationManager }
Use property
Kotlin (properties) @Singleton @Component(modules = arrayOf(AppModule::class)) interface AppComponent { val
context : Context val notificationManager : NotificationManager }
Realm
Constructor and properties
Primary constructor and default value
Java public class User extends RealmObject { @PrimaryKey private String
uuid; private String name; public User() { this(UUID.randomUUID().toString(), null); } public User(String uuid, String name) { this.uuid = uuid; this.name = name; } public String getUuid() {return uuid;} public void setUuid(String uuid) {this.uuid = uuid;} public String getName() {return name;} public void setName(String name) {this.name = name;} }
Kotlin (default constructor) class User constructor() : RealmObject() { @PrimaryKey
var uuid: String? = UUID.randomUUID().toString() var name: String? = null }
Kotlin (with default value) open class User( @PrimaryKey open var
uuid: String = UUID.randomUUID().toString(), open var name: String? = null ) : RealmObject() {}
Computed property in model class
Use extension property
Java public class User extends RealmObject { private Date createdDate;
@Ignore private Instant createdAt; public Date getCreatedDate() {return createdDate;} public void setCreatedDate(Date createdDate) {this.createdDate = createdDate;} public Instant getCreatedAt() { return DateTimeUtils.toInstant(getCreatedDate()); } public void setCreatedAt(Instant createdAt) { setCreatedDate(DateTimeUtils.toDate(createdAt)); } }
Kotlin (property) Not available
Kotlin (extension property) open class User( … open var createdDate:
Date? = null ) : RealmObject() {} var User.createdAt : Instant get() = DateTimeUtils.toInstant(createdDate) set(value) { createdDate = DateTimeUtils.toDate(value) }
Enjoy Kotlin life!