Slide 1

Slide 1 text

Convert your legacy (Android) app to Kotlin! Lovis Möller @lovisbrot #codetalkshh

Slide 2

Slide 2 text

Kotlin Lovis Möller @lovisbrot #codetalkshh

Slide 3

Slide 3 text

Kotlin • Developed by JetBrains Lovis Möller @lovisbrot #codetalkshh

Slide 4

Slide 4 text

Kotlin • Developed by JetBrains • Concise & Expressive Lovis Möller @lovisbrot #codetalkshh

Slide 5

Slide 5 text

Kotlin • Developed by JetBrains • Concise & Expressive • Pragmatic & Secure Lovis Möller @lovisbrot #codetalkshh

Slide 6

Slide 6 text

Kotlin • Developed by JetBrains • Concise & Expressive • Pragmatic & Secure • 100% interoperable with Java Lovis Möller @lovisbrot #codetalkshh

Slide 7

Slide 7 text

Kotlin • Developed by JetBrains • Concise & Expressive • Pragmatic & Secure • 100% interoperable with Java • Easy to learn for Java developers Lovis Möller @lovisbrot #codetalkshh

Slide 8

Slide 8 text

Live Demo Lovis Möller @lovisbrot #codetalkshh Example App: Thesaurus • Enter a word • See synonym results • Display errors, if any https://github.com/lmller/codetalks2017

Slide 9

Slide 9 text

Live Demo Lovis Möller @lovisbrot #codetalkshh 1. Java 2. Kotlin Dependencies 3. Model Classes 4. Api & Dependency Injection 5. Android Classes 6. Domain: ViewModels, Presenters,…

Slide 10

Slide 10 text

More Tricks Lovis Möller @lovisbrot #codetalkshh Replace oldskool GoF patterns with Kotlin Builder  apply function (or named constructor args) Decorator  Extension functions / function composition Interpreter  sealed classes Iterator  operator functions get() and iterator() Observer  Observable delegate Prototype  data classes Singleton  object declaration Strategy  functions Template Method  (top level) functions Visitor  Pattern matching / when https://github.com/lmller/gof-in-kotlin

Slide 11

Slide 11 text

More Tricks Lovis Möller @lovisbrot #codetalkshh Write your own extension functions fun ImageView.setImageUrl(url: String) { Picasso.with(context).load(url).into(this) } imageView.setImageUrl("http://...")

Slide 12

Slide 12 text

More Tricks Lovis Möller @lovisbrot #codetalkshh Write your own extension functions fun View.fadeIn() = animate().alpha(1f).setDuration(300)
 fun View.fadeOut() = animate().alpha(0f).setDuration(300) imageView.fadeIn()

Slide 13

Slide 13 text

More Tricks Lovis Möller @lovisbrot #codetalkshh Write your own extension properties val ViewParent.top
 get() = (this as View).top val patentTop = view.getParent().top

Slide 14

Slide 14 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based

Slide 15

Slide 15 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based • Rewrite from scratch

Slide 16

Slide 16 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based • Rewrite from scratch • Start with tests?

Slide 17

Slide 17 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based • Rewrite from scratch • Start with tests? • Not on Backlog • Whenever you touch a file, convert it • take the chance to improve the design!

Slide 18

Slide 18 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based • Rewrite from scratch • Start with tests? • Not on Backlog • Whenever you touch a file, convert it • take the chance to improve the design! • Don't go overboard

Slide 19

Slide 19 text

But how? Lovis Möller @lovisbrot #codetalkshh Strategies • Whole file or snippet-based • Rewrite from scratch • Start with tests? • Not on Backlog • Whenever you touch a file, convert it • take the chance to improve the design! • Don't go overboard • Keep it simple

Slide 20

Slide 20 text

Thanks a lot! Lovis Möller @lovisbrot #codetalkshh

Slide 21

Slide 21 text

Lovis Möller @lovisbrot #codetalkshh github.com/lmller/codetalks2017 github.com/lmller/gof-in-kotlin @lovisbrot magicline.com/de/karriere Examples meetup.com/Kotlin-User-Group-Hamburg