SlideShare a Scribd company logo
1 of 80
레진코믹스는 Kotlin을
어떻게 사용 하고 있을
까?
LazySoul
우명인
Why Kotlin ?
• Java 와 100% Interop
• 람다식, Higher-order function 사용 가능
• Java8은 가능 하지만, Android는 Java8을 제한적으로 사
용
• 보일러 플레이트들이 적음 (property, data class,
lambda…)
• null safe, kotlin extensions, collection Api, Lazy evaluation
…..
Why Java ?
• 익숙함?
• ……(성능?)
현재상황
Kotlin > Java
현재상황
현재상황
>
54
%
45
%
1%
현재상황
새로 작성 되는 코드들은 Kotlin
현재상황
기존 Java 코드를 수정해야 되는 경우, 시간적 여유가 있다면
Kotlin으로 변환
현재상황
리펙토링이 필요 할때 되도록 Kotlin으로
현재상황?
• 굳이 Java 코드를 Kotlin 으로 100% 바꿀 필요가 있을까?
현재상황?
• 굳이 Java 코드를 Kotlin 으로 100% 바꿀 필요가 있을까?
• 새로 작성 하는 코드는 Kotlin으로 작성 할 필요가 있을까?
Pros
Pros : Java Interop
Pros : Lambda Expression
view.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// do Something
}
})
Pros : Lambda Expression
view.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// do Something
}
})
Pros : Lambda Expression
view.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// do Something
}
})
Pros : Lambda Expression
view.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// do Something
}
})
Pros : Lambda Expression
view.setOnClickListener(object : View.OnClickListener {
override fun onClick(view: View?) {
// do Something
}
})
Pros : Lambda Expression
view.setOnClickListener {
// do Something
}
Pros : ValidationCheck
• require
• requireNotNull
• check
• checkNotNull
Pros : ValidationCheck
if (-1L == b.getLong(GrimmOptions.KEY_CONTENT_ID, -1)) {
throw IllegalArgumentException("No content id exists")
}
if (null == b.getString(GrimmOptions.KEY_CONTENT_ALIAS)) {
throw IllegalArgumentException("No content alias exists")
}
if (!b.containsKey(GrimmOptions.KEY_CONTENT_IMAGES)) {
throw IllegalArgumentException("No KEY_CONTENT_IMAGES exists")
}
if (-1L == b.getLong(GrimmOptions.KEY_EPISODE_ID, -1)) {
throw IllegalArgumentException("No episode id exists")
}
if (!b.containsKey(GrimmOptions.KEY_EPISODE_IS_PURCHASED)) {
throw IllegalArgumentException("No episode purchase data")
}
if (-1L == b.getLong(GrimmOptions.KEY_EPISODE_LAST_UPDATE_TIME)) {
throw IllegalArgumentException("No episode last update time")
}
if (!b.containsKey(GrimmOptions.KEY_EPISODE_DIRECTION)) {
throw IllegalArgumentException("No KEY_EPISODE_DIRECTION exists")
}
if (!b.containsKey(GrimmOptions.KEY_EPISODE_URI)) {
throw IllegalArgumentException("No KEY_EPISODE_URI exists")
}
Pros : ValidationCheck
require(-1L == b.getLong(GrimmOptions.KEY_CONTENT_ID, -1), { "No content id exists" })
requireNotNull(b.getString(GrimmOptions.KEY_CONTENT_ALIAS), { "No content alias exists" })
require(!b.containsKey(GrimmOptions.KEY_CONTENT_IMAGES), { "No KEY_CONTENT_IMAGES exists" })
require(-1L == b.getLong(GrimmOptions.KEY_EPISODE_ID, -1), { "No episode id exists" })
require(!b.containsKey(GrimmOptions.KEY_EPISODE_IS_PURCHASED), { "No episode purchase data" })
require(-1L == b.getLong(GrimmOptions.KEY_EPISODE_LAST_UPDATE_TIME), { "No episode last update time" })
require(!b.containsKey(GrimmOptions.KEY_EPISODE_DIRECTION), { "No KEY_EPISODE_DIRECTION exists" })
require(!b.containsKey(GrimmOptions.KEY_EPISODE_URI), { "No KEY_EPISODE_URI exists" })
Pros : Higher order function
View Presenter
Event
Pros : Higher order function
View Presenter
Event
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent)
}
Pros : Higher order function
View Presenter
UiUpdate
Event
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent)
}
Pros : Higher order function
View Presenter
UiUpdate
Event
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent)
}
fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent) {
kotlinEvent.consume()
mvpView.showToast("Kotlin")
}
Pros : Higher order function
View Presenter
UiUpdate
Event
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent)
}
fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent) {
kotlinEvent.consume()
mvpView.showToast("Kotlin")
}
override fun showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
Pros : Higher order function
View Presenter
Event
Action
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) })
}
override fun showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
Pros : Higher order function
View Presenter
Consume
Action()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) })
}
override fun showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
Event
Action
Pros : Higher order function
View Presenter
Consume
Action()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) })
}
override fun showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent, action: (String) -> Unit) {
kotlinEvent.consume()
action("Kotlin")
}
Event
Action
Pros : Higher order function
products
.filter { it.badge.contains(item.badges ?: "_EMPTY_") }
.filter { it.pointPrice == 0 }
.map { it.coin }
.toList()
Pros : Kotlin Extension
fun Int.toStringMax99(): String = if (this > 99) {
"99+"
} else {
this.toString()
}
Pros : Kotlin Extension
var View.visible: Boolean
get() = this.visibility == View.VISIBLE
set(value) = if (value) {
this.visibility = View.VISIBLE
} else {
this.visibility = View.GONE
}
Pros : Android Extension
• findViewById 지옥 에서 탈출
Pros : Android Extension
• findViewById 지옥 에서 탈출
textView = findViewById(R.id.tv_kotlin_activity)
textView2 = findViewById(R.id.tv_kotlin_activity2)
textView3 = findViewById(R.id.tv_kotlin_activity3)
imageView = findViewById(R.id.iv_kotlin_activity)
imageView2 = findViewById(R.id.iv_kotlin_activity2)
imageView3 = findViewById(R.id.iv_kotlin_activity3)
textView.text = "text1"
textView2.text = "text2"
textView3.text = "text3"
imageView.setImageResource(R.drawable.ic_photo_normal)
imageView2.setImageResource(R.drawable.ic_photo_normal)
imageView3.setImageResource(R.drawable.ic_photo_normal)
Pros : Android Extension
• findViewById 지옥 에서 탈출
textView = findViewById(R.id.tv_kotlin_activity)
textView2 = findViewById(R.id.tv_kotlin_activity2)
textView3 = findViewById(R.id.tv_kotlin_activity3)
imageView = findViewById(R.id.iv_kotlin_activity)
imageView2 = findViewById(R.id.iv_kotlin_activity2)
imageView3 = findViewById(R.id.iv_kotlin_activity3)
textView.text = "text1"
textView2.text = "text2"
textView3.text = "text3"
imageView.setImageResource(R.drawable.ic_photo_normal)
imageView2.setImageResource(R.drawable.ic_photo_normal)
imageView3.setImageResource(R.drawable.ic_photo_normal)
Pros : Android Extension
• findViewById 지옥 에서 탈출
import kotlinx.android.synthetic.main.kotlin_activity.*
tv_kotlin_activity.text = "text1"
tv_kotlin_activity2.text = "text2"
tv_kotlin_activity3.text = "text3"
iv_kotlin_activity.setImageResource(R.drawable.ic_photo_normal)
iv_kotlin_activity2.setImageResource(R.drawable.ic_photo_normal)
iv_kotlin_activity3.setImageResource(R.drawable.ic_photo_normal)
Pros : Lazy Evaluation
• lateInit
• Dependency Injection (Dagger)
Pros : Lazy Evaluation
• lateInit
• Dependency Injection (Dagger)
• runtime 에 set 되는 mutable property (var)
Pros : Lazy Evaluation
• lateInit
• Dependency Injection (Dagger)
• runtime 에 set 되는 mutable property (var)
• by lazy
• runtime에 set되는 read-only property (val)
Pros : Lazy Evaluation
• lateInit
• Dependency Injection (Dagger)
• runtime 에 set 되는 mutable property (var)
• by lazy
• runtime에 set되는 read-only property (val)
• 리소스가 많이 들거나 연산이 오래 걸리지만 자주 사용
하는 property
Pros : Lazy Evaluation
private val pdPending by lazy { ... }
private val presentAdapter by lazy {
...
}
lateinit @Inject var locale: LezhinLocale
lateinit @Inject var userApi: UserApi
lateinit @Inject var presenter: PresentBoxMvpPresenter
Pros : JoinToString
val sb = StringBuilder()
val size = items.size
for (i in 0..size - 1) {
sb.append(items[i].id)
if (i < size - 1) {
sb.append(‘, ')
}
} // item1, item2, item3..
item1
item2
item3
…
Pros : JoinToString
val sb = StringBuilder()
val size = items.size
for (i in 0..size - 1) {
sb.append(items[i].id)
if (i < size - 1) {
sb.append(‘, ')
}
} // item1, item2, item3..
items.joinToString(separator = “, ”)
// item1, item2, item3..
item1
item2
item3
…
Pros : Collection Api
• Rx를 사용해 iterable을 사용 할 필요가 없음.
Pros : Collection Api
• Rx를 사용해 iterable을 사용 할 필요가 없음.
• Higher order function 사용을 통해 가독성, 생산성 향상.
Pros : Collection Api
Observable.fromIterable(products)
.filter { it.badge.contains(item.badges ?: "_EMPTY_") }
.filter { it.pointPrice == 0 }
Pros : Collection Api
Observable.fromIterable(products)
.filter { it.badge.contains(item.badges ?: "_EMPTY_") }
.filter { it.pointPrice == 0 }
Pros : Collection Api
products
.filter { it.badge.contains(item.badges ?: "_EMPTY_") }
.filter { it.pointPrice == 0 }
Pros : Readability, Productivity
val margin = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 24f, resources.displayMetrics).toInt()
val lp = CoordinatorLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
lp.anchorId = R.id.rv_activity_main
lp.anchorGravity = Gravity.RIGHT or GravityCompat.END or Gravity.BOTTOM
lp.rightMargin = margin
lp.bottomMargin = margin
cl_activity_main.addView(button, lp)
Pros : Readability, Productivity
val margin = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 24f, resources.displayMetrics).toInt()
val lp = CoordinatorLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
anchorId = R.id.rv_activity_main
anchorGravity = Gravity.RIGHT or GravityCompat.END or Gravity.BOTTOM
rightMargin = margin
bottomMargin = margin
}
cl_activity_main.addView(button, lp)
Pros : Readability, Productivity
presenter.attachView(this@PresentBoxActivity)
presenter.loadBalance(token, userId)
presenter.loadItems(token, userId)
Pros : Readability, Productivity
presenter.attachView(this@PresentBoxActivity)
presenter.loadBalance(token, userId)
presenter.loadItems(token, userId)
with(presenter) {
attachView(this@PresentBoxActivity)
loadBalance(token, userId)
loadItems(token, userId)
}
Pros : Readability, Productivity
if (null != episode.topNotice) {
add(0, episode.topNotice.toContentImage(BuildConfig.CDN_HOST))
}
Pros : Readability, Productivity
episode.topNotice?.let {
add(0, it.toContentImage(BuildConfig.CDN_HOST))
}
Pros : Readability, Productivity
if(null != playerGroupPool[group]){
if(null != playerGroupPool[group]!![id]){
val palyerData = playerGroupPool[group]!![id]!!
palyerData.player.playWhenReady = false
palyerData.isRunning = false
}
}
Pros : Readability, Productivity
playerGroupPool[group]?.get(id)?.let {
with(it){
player.playWhenReady = false
isRunning = false
}
}
Pros : Readability, Productivity
playerGroupPool[group]?.get(id)?.run {
player.playWhenReady = false
isRunning = false
}
Pros : Readability, Productivity
override fun getItemViewType(position: Int): Int {
return when (position) {
items.size -> TYPE_FOOTER
else -> TYPE_ITEM
}
}
override fun getItemCount(): Int {
return items.size + 1
}
Pros : Readability, Productivity
override fun getItemViewType(position: Int): Int {
return when (position) {
items.size -> TYPE_FOOTER
else -> TYPE_ITEM
}
}
override fun getItemCount(): Int {
return items.size + 1
}
Pros : Readability, Productivity
override fun getItemViewType(position: Int): Int = when (position) {
items.size -> TYPE_FOOTER
else -> TYPE_ITEM
}
override fun getItemCount(): Int = items.size + 1
Pros : Confidence
Pros : FP
Kotlin FP
Pros : FP
Kotlin FP
FunFunStudy
gitHub : https://github.com/funfunStudy/study/wiki
facebook : https://www.facebook.com/groups/1189616354467814/?ref=bookmarks
Problems
Problem : 잘 사용 하고 있나??
Problem : kapt
Problem : FP 선무당..
Problem : Code Artist?
Problem : 개발자 구하기가…
Tips : Toy Project
Tips : Study
Tips : CodeReview
Tips : CodeReview
0
25
50
75
100
125
Time
Performance
2~3M
Tips : Progressive
Tips : Progressive
Business logicData UI
Tips : Progressive
리펙토링새로운 코드 작성
기존 코드를 수정
할 때
Tips : KtLint
https://github.com/shyiko/ktlint
configurations {
ktlint
}
dependencies {
ktlint 'com.github.shyiko:ktlint:0.9.0'
}
task ktlint(type: JavaExec) {
……
}
task ktlintFormat(type: JavaExec) {
……
}
afterEvaluate { project ->
check.dependsOn ktlint
}
Links
https://medium.com/@lazysoul
https://github.com/funfunStudy/study/wiki
https://www.facebook.com/groups/1189616354467814
http://tech.lezhin.com/
https://www.slideshare.net/myeonginwoo

More Related Content

What's hot

eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan s.r.o.
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in actionCiro Rizzo
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersBartosz Kosarzycki
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 FeaturesAndreas Enbohm
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Languageintelliyole
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Andrey Breslav
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript EngineKris Mok
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and SimpleBen Mabey
 
Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.JustSystems Corporation
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Groupbaroquebobcat
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvmArnaud Giuliani
 

What's hot (20)

eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 Features
 
Scala
ScalaScala
Scala
 
Hybrid Applications
Hybrid ApplicationsHybrid Applications
Hybrid Applications
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript Engine
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 
Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 

Similar to Lezhin kotlin jetbrain

Reactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsReactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsGabor Varadi
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorTrayan Iliev
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?intelliyole
 
Python在豆瓣的应用
Python在豆瓣的应用Python在豆瓣的应用
Python在豆瓣的应用Qiangning Hong
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainersSunghyouk Bae
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 
Perf onjs final
Perf onjs finalPerf onjs final
Perf onjs finalqi yang
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBBoxed Ice
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IICS
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best PracticesBurt Beckwith
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Managementstable|kernel
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin PresentationAndrzej Sitek
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...Jerry Chou
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Sunghyouk Bae
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCanSecWest
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with ReduxFITC
 

Similar to Lezhin kotlin jetbrain (20)

Reactive state management with Jetpack Components
Reactive state management with Jetpack ComponentsReactive state management with Jetpack Components
Reactive state management with Jetpack Components
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and Ktor
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?
 
Python在豆瓣的应用
Python在豆瓣的应用Python在豆瓣的应用
Python在豆瓣的应用
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Kotlin talk
Kotlin talkKotlin talk
Kotlin talk
 
Attribute
AttributeAttribute
Attribute
 
Perf onjs final
Perf onjs finalPerf onjs final
Perf onjs final
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
[PyCon 2014 APAC] How to integrate python into a scala stack to build realtim...
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 

More from Myeongin Woo

DroidKnight 2018 State machine by Selaed class
DroidKnight 2018 State machine by Selaed classDroidKnight 2018 State machine by Selaed class
DroidKnight 2018 State machine by Selaed classMyeongin Woo
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collectionsMyeongin Woo
 
토이 프로젝트를 하자.Pptx
토이 프로젝트를 하자.Pptx토이 프로젝트를 하자.Pptx
토이 프로젝트를 하자.PptxMyeongin Woo
 

More from Myeongin Woo (10)

Goodbye null
Goodbye nullGoodbye null
Goodbye null
 
Fp basic-kotlin
Fp basic-kotlinFp basic-kotlin
Fp basic-kotlin
 
DroidKnight 2018 State machine by Selaed class
DroidKnight 2018 State machine by Selaed classDroidKnight 2018 State machine by Selaed class
DroidKnight 2018 State machine by Selaed class
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
Kotlin standard
Kotlin standardKotlin standard
Kotlin standard
 
Kotlin class
Kotlin classKotlin class
Kotlin class
 
Kotlin expression
Kotlin expressionKotlin expression
Kotlin expression
 
Kotlin with fp
Kotlin with fpKotlin with fp
Kotlin with fp
 
토이 프로젝트를 하자.Pptx
토이 프로젝트를 하자.Pptx토이 프로젝트를 하자.Pptx
토이 프로젝트를 하자.Pptx
 
Kotlin.md
Kotlin.mdKotlin.md
Kotlin.md
 

Recently uploaded

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Recently uploaded (20)

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Lezhin kotlin jetbrain

  • 1. 레진코믹스는 Kotlin을 어떻게 사용 하고 있을 까? LazySoul 우명인
  • 2. Why Kotlin ? • Java 와 100% Interop • 람다식, Higher-order function 사용 가능 • Java8은 가능 하지만, Android는 Java8을 제한적으로 사 용 • 보일러 플레이트들이 적음 (property, data class, lambda…) • null safe, kotlin extensions, collection Api, Lazy evaluation …..
  • 3. Why Java ? • 익숙함? • ……(성능?)
  • 7. 현재상황 새로 작성 되는 코드들은 Kotlin
  • 8. 현재상황 기존 Java 코드를 수정해야 되는 경우, 시간적 여유가 있다면 Kotlin으로 변환
  • 10. 현재상황? • 굳이 Java 코드를 Kotlin 으로 100% 바꿀 필요가 있을까?
  • 11. 현재상황? • 굳이 Java 코드를 Kotlin 으로 100% 바꿀 필요가 있을까? • 새로 작성 하는 코드는 Kotlin으로 작성 할 필요가 있을까?
  • 12. Pros
  • 13. Pros : Java Interop
  • 14. Pros : Lambda Expression view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // do Something } })
  • 15. Pros : Lambda Expression view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // do Something } })
  • 16. Pros : Lambda Expression view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // do Something } })
  • 17. Pros : Lambda Expression view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // do Something } })
  • 18. Pros : Lambda Expression view.setOnClickListener(object : View.OnClickListener { override fun onClick(view: View?) { // do Something } })
  • 19. Pros : Lambda Expression view.setOnClickListener { // do Something }
  • 20. Pros : ValidationCheck • require • requireNotNull • check • checkNotNull
  • 21. Pros : ValidationCheck if (-1L == b.getLong(GrimmOptions.KEY_CONTENT_ID, -1)) { throw IllegalArgumentException("No content id exists") } if (null == b.getString(GrimmOptions.KEY_CONTENT_ALIAS)) { throw IllegalArgumentException("No content alias exists") } if (!b.containsKey(GrimmOptions.KEY_CONTENT_IMAGES)) { throw IllegalArgumentException("No KEY_CONTENT_IMAGES exists") } if (-1L == b.getLong(GrimmOptions.KEY_EPISODE_ID, -1)) { throw IllegalArgumentException("No episode id exists") } if (!b.containsKey(GrimmOptions.KEY_EPISODE_IS_PURCHASED)) { throw IllegalArgumentException("No episode purchase data") } if (-1L == b.getLong(GrimmOptions.KEY_EPISODE_LAST_UPDATE_TIME)) { throw IllegalArgumentException("No episode last update time") } if (!b.containsKey(GrimmOptions.KEY_EPISODE_DIRECTION)) { throw IllegalArgumentException("No KEY_EPISODE_DIRECTION exists") } if (!b.containsKey(GrimmOptions.KEY_EPISODE_URI)) { throw IllegalArgumentException("No KEY_EPISODE_URI exists") }
  • 22. Pros : ValidationCheck require(-1L == b.getLong(GrimmOptions.KEY_CONTENT_ID, -1), { "No content id exists" }) requireNotNull(b.getString(GrimmOptions.KEY_CONTENT_ALIAS), { "No content alias exists" }) require(!b.containsKey(GrimmOptions.KEY_CONTENT_IMAGES), { "No KEY_CONTENT_IMAGES exists" }) require(-1L == b.getLong(GrimmOptions.KEY_EPISODE_ID, -1), { "No episode id exists" }) require(!b.containsKey(GrimmOptions.KEY_EPISODE_IS_PURCHASED), { "No episode purchase data" }) require(-1L == b.getLong(GrimmOptions.KEY_EPISODE_LAST_UPDATE_TIME), { "No episode last update time" }) require(!b.containsKey(GrimmOptions.KEY_EPISODE_DIRECTION), { "No KEY_EPISODE_DIRECTION exists" }) require(!b.containsKey(GrimmOptions.KEY_EPISODE_URI), { "No KEY_EPISODE_URI exists" })
  • 23. Pros : Higher order function View Presenter Event
  • 24. Pros : Higher order function View Presenter Event override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent) }
  • 25. Pros : Higher order function View Presenter UiUpdate Event override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent) }
  • 26. Pros : Higher order function View Presenter UiUpdate Event override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent) } fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent) { kotlinEvent.consume() mvpView.showToast("Kotlin") }
  • 27. Pros : Higher order function View Presenter UiUpdate Event override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent) } fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent) { kotlinEvent.consume() mvpView.showToast("Kotlin") } override fun showToast(msg: String) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() }
  • 28. Pros : Higher order function View Presenter Event Action override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) }) } override fun showToast(msg: String) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() }
  • 29. Pros : Higher order function View Presenter Consume Action() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) }) } override fun showToast(msg: String) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() } Event Action
  • 30. Pros : Higher order function View Presenter Consume Action() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) kotlinPresenter.someProcess(kotlinEvent, { msg -> showToast(msg) }) } override fun showToast(msg: String) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() } fun someProcess(kotlinEvent: KotlinActivity.KotlinEvent, action: (String) -> Unit) { kotlinEvent.consume() action("Kotlin") } Event Action
  • 31. Pros : Higher order function products .filter { it.badge.contains(item.badges ?: "_EMPTY_") } .filter { it.pointPrice == 0 } .map { it.coin } .toList()
  • 32. Pros : Kotlin Extension fun Int.toStringMax99(): String = if (this > 99) { "99+" } else { this.toString() }
  • 33. Pros : Kotlin Extension var View.visible: Boolean get() = this.visibility == View.VISIBLE set(value) = if (value) { this.visibility = View.VISIBLE } else { this.visibility = View.GONE }
  • 34. Pros : Android Extension • findViewById 지옥 에서 탈출
  • 35. Pros : Android Extension • findViewById 지옥 에서 탈출 textView = findViewById(R.id.tv_kotlin_activity) textView2 = findViewById(R.id.tv_kotlin_activity2) textView3 = findViewById(R.id.tv_kotlin_activity3) imageView = findViewById(R.id.iv_kotlin_activity) imageView2 = findViewById(R.id.iv_kotlin_activity2) imageView3 = findViewById(R.id.iv_kotlin_activity3) textView.text = "text1" textView2.text = "text2" textView3.text = "text3" imageView.setImageResource(R.drawable.ic_photo_normal) imageView2.setImageResource(R.drawable.ic_photo_normal) imageView3.setImageResource(R.drawable.ic_photo_normal)
  • 36. Pros : Android Extension • findViewById 지옥 에서 탈출 textView = findViewById(R.id.tv_kotlin_activity) textView2 = findViewById(R.id.tv_kotlin_activity2) textView3 = findViewById(R.id.tv_kotlin_activity3) imageView = findViewById(R.id.iv_kotlin_activity) imageView2 = findViewById(R.id.iv_kotlin_activity2) imageView3 = findViewById(R.id.iv_kotlin_activity3) textView.text = "text1" textView2.text = "text2" textView3.text = "text3" imageView.setImageResource(R.drawable.ic_photo_normal) imageView2.setImageResource(R.drawable.ic_photo_normal) imageView3.setImageResource(R.drawable.ic_photo_normal)
  • 37. Pros : Android Extension • findViewById 지옥 에서 탈출 import kotlinx.android.synthetic.main.kotlin_activity.* tv_kotlin_activity.text = "text1" tv_kotlin_activity2.text = "text2" tv_kotlin_activity3.text = "text3" iv_kotlin_activity.setImageResource(R.drawable.ic_photo_normal) iv_kotlin_activity2.setImageResource(R.drawable.ic_photo_normal) iv_kotlin_activity3.setImageResource(R.drawable.ic_photo_normal)
  • 38. Pros : Lazy Evaluation • lateInit • Dependency Injection (Dagger)
  • 39. Pros : Lazy Evaluation • lateInit • Dependency Injection (Dagger) • runtime 에 set 되는 mutable property (var)
  • 40. Pros : Lazy Evaluation • lateInit • Dependency Injection (Dagger) • runtime 에 set 되는 mutable property (var) • by lazy • runtime에 set되는 read-only property (val)
  • 41. Pros : Lazy Evaluation • lateInit • Dependency Injection (Dagger) • runtime 에 set 되는 mutable property (var) • by lazy • runtime에 set되는 read-only property (val) • 리소스가 많이 들거나 연산이 오래 걸리지만 자주 사용 하는 property
  • 42. Pros : Lazy Evaluation private val pdPending by lazy { ... } private val presentAdapter by lazy { ... } lateinit @Inject var locale: LezhinLocale lateinit @Inject var userApi: UserApi lateinit @Inject var presenter: PresentBoxMvpPresenter
  • 43. Pros : JoinToString val sb = StringBuilder() val size = items.size for (i in 0..size - 1) { sb.append(items[i].id) if (i < size - 1) { sb.append(‘, ') } } // item1, item2, item3.. item1 item2 item3 …
  • 44. Pros : JoinToString val sb = StringBuilder() val size = items.size for (i in 0..size - 1) { sb.append(items[i].id) if (i < size - 1) { sb.append(‘, ') } } // item1, item2, item3.. items.joinToString(separator = “, ”) // item1, item2, item3.. item1 item2 item3 …
  • 45. Pros : Collection Api • Rx를 사용해 iterable을 사용 할 필요가 없음.
  • 46. Pros : Collection Api • Rx를 사용해 iterable을 사용 할 필요가 없음. • Higher order function 사용을 통해 가독성, 생산성 향상.
  • 47. Pros : Collection Api Observable.fromIterable(products) .filter { it.badge.contains(item.badges ?: "_EMPTY_") } .filter { it.pointPrice == 0 }
  • 48. Pros : Collection Api Observable.fromIterable(products) .filter { it.badge.contains(item.badges ?: "_EMPTY_") } .filter { it.pointPrice == 0 }
  • 49. Pros : Collection Api products .filter { it.badge.contains(item.badges ?: "_EMPTY_") } .filter { it.pointPrice == 0 }
  • 50. Pros : Readability, Productivity val margin = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 24f, resources.displayMetrics).toInt() val lp = CoordinatorLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) lp.anchorId = R.id.rv_activity_main lp.anchorGravity = Gravity.RIGHT or GravityCompat.END or Gravity.BOTTOM lp.rightMargin = margin lp.bottomMargin = margin cl_activity_main.addView(button, lp)
  • 51. Pros : Readability, Productivity val margin = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 24f, resources.displayMetrics).toInt() val lp = CoordinatorLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { anchorId = R.id.rv_activity_main anchorGravity = Gravity.RIGHT or GravityCompat.END or Gravity.BOTTOM rightMargin = margin bottomMargin = margin } cl_activity_main.addView(button, lp)
  • 52. Pros : Readability, Productivity presenter.attachView(this@PresentBoxActivity) presenter.loadBalance(token, userId) presenter.loadItems(token, userId)
  • 53. Pros : Readability, Productivity presenter.attachView(this@PresentBoxActivity) presenter.loadBalance(token, userId) presenter.loadItems(token, userId) with(presenter) { attachView(this@PresentBoxActivity) loadBalance(token, userId) loadItems(token, userId) }
  • 54. Pros : Readability, Productivity if (null != episode.topNotice) { add(0, episode.topNotice.toContentImage(BuildConfig.CDN_HOST)) }
  • 55. Pros : Readability, Productivity episode.topNotice?.let { add(0, it.toContentImage(BuildConfig.CDN_HOST)) }
  • 56. Pros : Readability, Productivity if(null != playerGroupPool[group]){ if(null != playerGroupPool[group]!![id]){ val palyerData = playerGroupPool[group]!![id]!! palyerData.player.playWhenReady = false palyerData.isRunning = false } }
  • 57. Pros : Readability, Productivity playerGroupPool[group]?.get(id)?.let { with(it){ player.playWhenReady = false isRunning = false } }
  • 58. Pros : Readability, Productivity playerGroupPool[group]?.get(id)?.run { player.playWhenReady = false isRunning = false }
  • 59. Pros : Readability, Productivity override fun getItemViewType(position: Int): Int { return when (position) { items.size -> TYPE_FOOTER else -> TYPE_ITEM } } override fun getItemCount(): Int { return items.size + 1 }
  • 60. Pros : Readability, Productivity override fun getItemViewType(position: Int): Int { return when (position) { items.size -> TYPE_FOOTER else -> TYPE_ITEM } } override fun getItemCount(): Int { return items.size + 1 }
  • 61. Pros : Readability, Productivity override fun getItemViewType(position: Int): Int = when (position) { items.size -> TYPE_FOOTER else -> TYPE_ITEM } override fun getItemCount(): Int = items.size + 1
  • 64. Pros : FP Kotlin FP FunFunStudy gitHub : https://github.com/funfunStudy/study/wiki facebook : https://www.facebook.com/groups/1189616354467814/?ref=bookmarks
  • 66. Problem : 잘 사용 하고 있나??
  • 68. Problem : FP 선무당..
  • 69. Problem : Code Artist?
  • 70. Problem : 개발자 구하기가…
  • 71.
  • 72. Tips : Toy Project
  • 78. Tips : Progressive 리펙토링새로운 코드 작성 기존 코드를 수정 할 때
  • 79. Tips : KtLint https://github.com/shyiko/ktlint configurations { ktlint } dependencies { ktlint 'com.github.shyiko:ktlint:0.9.0' } task ktlint(type: JavaExec) { …… } task ktlintFormat(type: JavaExec) { …… } afterEvaluate { project -> check.dependsOn ktlint }