PROPOSED (KOTLIN)
interface SomeInterface {
fun doAThing()
}
Slide 66
Slide 66 text
PROPOSED (KOTLIN)
interface SomeInterface {
fun doAThing()
}
@DefaultImpl
SomeInterface {
fun doAThing() {
println("Hi, I'm the default implementation!")
}
}
Slide 67
Slide 67 text
@JVMDefault + DefaultImpl
(SORT OF)
Slide 68
Slide 68 text
SEALED CLASSES
Slide 69
Slide 69 text
KOTLIN
sealed class ViewState {
class Empty(val placeholder: View): ViewState()
class HasContent(val items: List): ViewState()
}
Slide 70
Slide 70 text
KOTLIN
sealed class ViewState {
class Empty(val placeholder: View): ViewState()
class HasContent(val items: List): ViewState()
}
when (state) {
is ViewState.Empty --> display(it.placeholder)
is ViewState.HasContent --> adapter.reloadWith(it.items)
}
Slide 71
Slide 71 text
SWIFT
enum TableViewState {
case empty(placeholderView: UIView)
case loaded(items: [Item])
}
switch state {
case .empty(let placeholder):
display(placeholder)
case .hasContent(let items):
dataSource.reloadWith(items)
}
Slide 72
Slide 72 text
KOTLIN
sealed class ViewState {
class Empty(val placeholder: View): ViewState()
class HasContent(val items: List): ViewState()
}
Slide 73
Slide 73 text
KOTLIN
sealed class ViewState {
class Empty(val placeholder: View): ViewState()
class HasContent(val items: List): ViewState() {
val adapter = RecyclerViewAdapter(items)
fun selectedItem(item: Item) {
// Do something ith the selected item
}
}
}
A KOTLIN ENUM CLASS IN A KOTLIN / NATIVE FRAMEWORK
Slide 123
Slide 123 text
A KOTLIN ENUM CLASS IN A KOTLIN / NATIVE FRAMEWORK
Slide 124
Slide 124 text
A KOTLIN ENUM CLASS IN A KOTLIN / NATIVE FRAMEWORK
Slide 125
Slide 125 text
SWIFT SWITCHING ON A KOTLIN ENUM
switch day {
case .monday:
print("You can fall apart")
case .tuesday,
.wednesday:
print("Break my heart")
case .thursday:
print("Doesn't even start")
case .friday:
print("I'm in love")
case .saturday:
print("Wait")
case .sunday:
print("Always comes too late")
}
//
!
Seems legit...
Slide 126
Slide 126 text
SWIFT SWITCHING ON A KOTLIN ENUM
switch day {
case .monday:
print("You can fall apart")
case .tuesday,
.wednesday:
print("Break my heart")
case .thursday:
print("Doesn't even start")
case .friday:
print("I'm in love")
case .saturday:
print("Wait")
case .sunday:
print("Always comes too late")
}
//
!
ERROR:
!
Switch must be exhaustive
Slide 127
Slide 127 text
SWIFT SWITCHING ON A KOTLIN ENUM
switch day {
case .monday:
print("You can fall apart")
case .tuesday,
.wednesday:
print("Break my heart")
case .thursday:
print("Doesn't even start")
case .friday:
print("I'm in love")
case .saturday:
print("Wait")
case .sunday:
print("Always comes too late")
default:
fatalError("Not a day") //
!
}
Slide 128
Slide 128 text
DOCUMENTATION
Slide 129
Slide 129 text
DOCUMENTATION?
¯\_(ϑ)_/¯
Slide 130
Slide 130 text
No content
Slide 131
Slide 131 text
PRODUCTION?!
Slide 132
Slide 132 text
KOTLIN:
☕
OR
"
=
Slide 133
Slide 133 text
try? kotlin
Slide 134
Slide 134 text
https://try.kotlinlang.org
Slide 135
Slide 135 text
No content
Slide 136
Slide 136 text
No content
Slide 137
Slide 137 text
EDU TOOLS
PLUGIN FOR INTELLIJ OR ANDROID STUDIO
Slide 138
Slide 138 text
No content
Slide 139
Slide 139 text
No content
Slide 140
Slide 140 text
OBLIGATORY SUMMARY SLIDE
Slide 141
Slide 141 text
OBLIGATORY SUMMARY SLIDE
▸ Literally put the fun in functional programming
Slide 142
Slide 142 text
OBLIGATORY SUMMARY SLIDE
▸ Literally put the fun in functional programming
▸ Make Friends With Android
Slide 143
Slide 143 text
OBLIGATORY SUMMARY SLIDE
▸ Literally put the fun in functional programming
▸ Make Friends With Android
▸ Kotlin Native Could Be A Whole New World
Slide 144
Slide 144 text
OBLIGATORY SUMMARY SLIDE
▸ Literally put the fun in functional programming
▸ Make Friends With Android
▸ Kotlin Native Could Be A Whole New World
▸ try! Kotlin
MORE LINKS!
▸ The Edu Tools Plugin for IntelliJ or Android Studio
https://kotlinlang.org/docs/tutorials/
edu-tools-learner.html
▸ Representing State (KotlinConf talk on Sealed Classes)
https://www.youtube.com/watch?v=-
lVVfxsRjcY
▸ Sealed Classes Opened My Mind (KotlinConf Talk)
https://www.youtube.com/watch?
v=uGMm3StjqLI
Slide 151
Slide 151 text
SHAMELESS SELF-PROMOTION!
▸ My talk on Protocol-Oriented Programming from Dot Swift
https://www.dotconferences.com/2018/01/
ellen-shapiro-protocols-all-the-way-down
▸ Kotlin Apprentice
https://store.raywenderlich.com/products/
kotlin-apprentice
▸ Android Apprentice
https://store.raywenderlich.com/products/
android-apprentice