luram archanjo · 2019-07-20 · migration: kotlin supports gradual, step by step migration of...
TRANSCRIPT
![Page 1: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/1.jpg)
Evolutionary Architecture: Evolving even the language
Luram Archanjo
![Page 2: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/2.jpg)
Who am I?● Software Engineer at Sensedia
● MBA in Java projects
● Java and Microservice enthusiastic
![Page 3: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/3.jpg)
Agenda
● Use case
● Microservices
● Evolutionary Architecture
● Challenges to adopt Kotlin
● Kotlin benefits
● Questions
![Page 4: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/4.jpg)
Use case
![Page 5: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/5.jpg)
Use case
Token Service Provider
Tokenization reduces the value of stored payment credentials by removing consumers’ primary account numbers (PANs) from the transaction process. It does this by replacing them with a unique identifier called a payment token.
This reduces the appeal of stealing the credentials as they would be largely useless to hackers.
Source: https://www.rambus.com/blogs/what-is-a-token-service-provider/
![Page 6: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/6.jpg)
Use case
![Page 7: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/7.jpg)
Microservices
![Page 8: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/8.jpg)
Moving to Microservices
Feature A
Feature B
Feature C
Monolith
Microservice Microservice
Microservices
Microservice
![Page 9: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/9.jpg)
Technological Heterogeneity
Microservice Microservice Microservice
DB DB DB
![Page 10: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/10.jpg)
Evolutionary Architecture
![Page 11: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/11.jpg)
Evolutionary Architecture
An evolutionary architecture supports guided, incremental change as a first principle across multiple dimensions.
Source: https://www.thoughtworks.com/books/building-evolutionary-architectures
![Page 12: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/12.jpg)
Our stack
![Page 13: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/13.jpg)
Evolutionary Architecture
Languages
Technologies
Databases
![Page 14: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/14.jpg)
All(15) microservices were written in
![Page 15: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/15.jpg)
We wanted to change, but there were many challenges!
![Page 16: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/16.jpg)
● Expertise in Java Frameworks e.g: Spring Stack, Hibernate etc.
● Expertise in Object-Oriented Programming
● Learning curve, sprint in progress
Evolutionary Architecture
![Page 17: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/17.jpg)
is going to overcome all of those challenges?
![Page 18: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/18.jpg)
Yes!!!
![Page 19: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/19.jpg)
Expertise in Java FrameworksExpertise in Object-Oriented Programming
Learning curve, sprint in progress
![Page 20: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/20.jpg)
Expertise in Java Frameworks
Interoperability: Kotlin is fully compatible with all Java-based frameworks, which lets you stay on your familiar technology stack while reaping the benefits of a more modern language.
Java code Kotlin code
Java Virtual Machine (JVM)
Bytecode
Source: https://kotlinlang.org/docs/reference/server-overview.html
![Page 21: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/21.jpg)
Expertise in Java Frameworks
![Page 22: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/22.jpg)
Expertise in Java Frameworks
Expertise in Object-Oriented Programming
Learning curve, sprint in progress
![Page 23: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/23.jpg)
Expertise in Object-Oriented Programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data, in the form of fields (often known as attributes), and code, in the form of procedures (often known as methods).
Source: https://en.wikipedia.org/wiki/Object-oriented_programming
Code
data class Person(val firstName: String, val surname: String, val age: Int) {
fun fullName() = "$firstName $surname"
}
![Page 24: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/24.jpg)
Expertise in Object-Oriented Programming
Functional programming is a programming paradigm based structures and elements of computer programs, that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
Source: https://en.wikipedia.org/wiki/Functional_programming
Code
data class Person(val name: String, String, val age: Int)
val persons = listOf(Person("Person 1", 15), Person("Person 2", 22))
persons.filter { person -> person.age >= 18 }
![Page 25: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/25.jpg)
Expertise in Java FrameworksExpertise in Object-Oriented Programming
Learning curve, sprint in progress
![Page 26: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/26.jpg)
Learning curve, sprint in progress
Source: https://kotlinlang.org/docs/reference/server-overview.html
Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while keeping older parts of your system in Java.
Microservice
Java
Microservice
Java
Kotlin
Microservice
Kotlin
![Page 27: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/27.jpg)
Learning curve, sprint in progress
![Page 28: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/28.jpg)
Kotlin benefits
![Page 29: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/29.jpg)
40% less code
![Page 30: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/30.jpg)
40% less code
Javapublic class Person { private final String name; private final Integer age;
public Person(String name, Integer age) { this.name = name; this.age = age; }
public String getName() { return name; }
public Integer getAge() { return age; }
}
Kotlin
data class Person(val name: String, val age: Int)
Default Values
data class Person(val name: String = "Unknown", val age: Int = 0)
Initializationval person = Person("Luram Archanjo", 25)
val person = Person() // Name = Unknown & age = 0
![Page 31: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/31.jpg)
Null Safety
![Page 32: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/32.jpg)
Null Safety
Java
final Person person = null; // accept null
person.getName().length();
Exception java.lang.NullPointerException
Kotlin
val person: Person = null // compilation error
val person: Person? = null // accept null
person.name.length // compilation error
Safe Calls
person?.name?.length // return null
Elvis Operator
person?.name?.length ?: 0 // return 0 if null
![Page 33: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/33.jpg)
Performs lots of checks, reducing runtime errors and the number of bugs in the
code
![Page 34: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/34.jpg)
Who is using Kotlin?Why?
![Page 35: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/35.jpg)
Who is using Kotlin? Why?
Source: https://github.com/ygaller/kotlin-companies/wiki
![Page 36: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/36.jpg)
Fail-fast principle=
Time to market
![Page 37: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/37.jpg)
Summary
2º Place
1º Place
3º PlaceInteroperable with Java
● Known frameworks
● Low learn curve
Concise
● Easier to maintain
● Easier to read
● Easier to apply changes when necessary
Modern
● Safe compiler
● Type interface
● Collection
● Lambdas
![Page 38: Luram Archanjo · 2019-07-20 · Migration: Kotlin supports gradual, step by step migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while](https://reader034.vdocuments.mx/reader034/viewer/2022050406/5f832a2364007a4f65445fe0/html5/thumbnails/38.jpg)
Thanks a million!Questions?
/larchanjo
/luram-archanjo