SlideShare a Scribd company logo
1 of 28
Migrating our micro services
from Java to Kotlin
Yet another awesome journey
2
Björn Wendland
Full-Stack Developer
@BjoernWendland
3
M|SHOP Picture
Our Migration Journey
Why we migrated from Java to Kotlin
5
Controversial
Java Features
Checked exceptions
7
public static void refundExcessMoney() throws ExternalPspFailureException {
// try to refund money
throw new ExternalPspFailureException();
}
try {
refundExcessMoney()
} catch (ExternalPspFailureException e) {
// log or rethrow
}
Single abstract method types
8
public interface Comparator<T> {
public boolean compare(T a, T b);
}
public class PaymentComparator implements Comparator<PaymentInformation> {
@Overwrite
public boolean compare(PaymentInformation a, PaymentInformation b) {
...
}
}
Wildcard-types
9
// use-site wildcard
List<?> paymentRawTypes = new ArrayList<Integer>();
void original(List<Number> paymentRawTypes) { }
void withWildcard(List<? extends Number> paymentRawTypes) { }
// Kotlin use-site variance
var paymentRawTypes = listOf(1, 2, 3)
Beneficial
KotlinFeatures
Null-safety
11
// non null-able
var paymentInformationId: UUID = UUID.randomUUID()
paymentInformationId = null // compilation error
// null-able
var paymentInformationId : UUID? = UUID.randomUUID()
paymentInformationId = null // ok
Extension functions
12
// Java
List<OrderId> orderIds = new ArrayList( Arrays.asList(id1, id2, id3) );
return JsonUtils.toJson(orderIds);
// Kotlin
val orderIds = listOf(id1, id2, id3)
return orderIds.toJson()
Smart casts
13
// Java
if (payment instanceof CreditCardPayment) {
CreditCardPayment ccPayment = (CreditCardPayment) payment;
return ccPayment.getCardHolder();
}
// Kotlin
if (payment is CreditCardPayment) {
return payment.cardHolder
}
Coroutines
Payment capture flow
15
PAY FEED PSPOM
write
feed
poll
status
request
capture
capture
poll
feed
fun capturePayment() {
val lastKnownEventId = feedsService.getLatestEventId()
paymentService.capture()
val feedStatus = getFeedStatus(lastKnownEventId)
feedStatus.whenError {
throw CreditCardCaptureException()
}
}
Request capture
16
Asynchronous feed reader
17
fun getFeedStatus(lastKnownEventId: UUID?): PaymentFeedStatus {
return runBlocking {
withTimeout(syncClientTimeout) {
var paymentFeedEvent: PaymentFeedEvent?
do {
paymentFeedEvent = feedsService.getSuccessorEventFor(lastKnownEventId)
delay(200)
} while (paymentFeedEvent.isNull())
paymentFeedEvent?.getStatus()
}
}
}
18
Our Journey Continues
What did we migrate
19
How did we migrate
20
refactor to
idiomatic
Kotlin
verify
using tests
fix invalid
code
automatic
code
conversion
Rewrite
everything
Switching to Kotlin frameworks
22
 KTOR - asynchronous Kotlin web framework
 Spring Boot - established Java web framework
 Often less matured
 Often less documented
No need to forcefully use
Kotlin libraries and frameworks
Review and Outlook
Review
24
 Challenge which we mastered as team
 Migrating was worth the effort
 Improved design and new focus on language
 Quality of life update
10/10 would use Kotlin again
A heads up
25
 Test coverage is a must have
 Consider your people and eco system
 Consider language and framework maturity level
 Amount of new things can be overwhelming
Outlook
26
 Establish Kotlin at METRONOM
 Help others introduce Kotlin
 Introduce more native Kotlin frameworks
 Find new passionate developers
Follow us on Twitter and Instagram
@bjoernwendland
@joinmetronomnow
#METRONOMians #wearedevs19 #passion #ambition #purpose
Hall A
Booth A11
@BjoernWendland
28
Thank you for
your attention!

More Related Content

What's hot

Accessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainAccessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainGene Leybzon
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous callsHuy Hoàng Phạm
 
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comMcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comkashif kashif
 
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2MongoDB
 
Hello world contract
Hello world contractHello world contract
Hello world contractGene Leybzon
 
Advanced functional programing in Swift
Advanced functional programing in SwiftAdvanced functional programing in Swift
Advanced functional programing in SwiftVincent Pradeilles
 
Programming clients-slides
Programming clients-slidesProgramming clients-slides
Programming clients-slidesMasterCode.vn
 
Introducing wcf-slides
Introducing wcf-slidesIntroducing wcf-slides
Introducing wcf-slidesMasterCode.vn
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp
 
Grailsでドメイン駆動設計を実践する時の勘所
Grailsでドメイン駆動設計を実践する時の勘所Grailsでドメイン駆動設計を実践する時の勘所
Grailsでドメイン駆動設計を実践する時の勘所Takuma Watabiki
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solvingSyed Umair
 
RxJS ‘Marble’ programming
RxJS ‘Marble’ programmingRxJS ‘Marble’ programming
RxJS ‘Marble’ programmingStas Rivkin
 
Velocity 2014: Accelerate Your User Experience With Client-side JavaScript
Velocity 2014: Accelerate Your User Experience With Client-side JavaScriptVelocity 2014: Accelerate Your User Experience With Client-side JavaScript
Velocity 2014: Accelerate Your User Experience With Client-side JavaScriptIntuit Inc.
 

What's hot (16)

Accessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchainAccessing decentralized finance on Ethereum blockchain
Accessing decentralized finance on Ethereum blockchain
 
The evolution of java script asynchronous calls
The evolution of java script asynchronous callsThe evolution of java script asynchronous calls
The evolution of java script asynchronous calls
 
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comMcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
 
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
 
Hello world contract
Hello world contractHello world contract
Hello world contract
 
Advanced functional programing in Swift
Advanced functional programing in SwiftAdvanced functional programing in Swift
Advanced functional programing in Swift
 
Programming clients-slides
Programming clients-slidesProgramming clients-slides
Programming clients-slides
 
Introducing wcf-slides
Introducing wcf-slidesIntroducing wcf-slides
Introducing wcf-slides
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
Grailsでドメイン駆動設計を実践する時の勘所
Grailsでドメイン駆動設計を実践する時の勘所Grailsでドメイン駆動設計を実践する時の勘所
Grailsでドメイン駆動設計を実践する時の勘所
 
Lecture04
Lecture04Lecture04
Lecture04
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Design Patterns in .Net
Design Patterns in .NetDesign Patterns in .Net
Design Patterns in .Net
 
RxJS ‘Marble’ programming
RxJS ‘Marble’ programmingRxJS ‘Marble’ programming
RxJS ‘Marble’ programming
 
openconfigd
openconfigdopenconfigd
openconfigd
 
Velocity 2014: Accelerate Your User Experience With Client-side JavaScript
Velocity 2014: Accelerate Your User Experience With Client-side JavaScriptVelocity 2014: Accelerate Your User Experience With Client-side JavaScript
Velocity 2014: Accelerate Your User Experience With Client-side JavaScript
 

Similar to Migrating our micro services from Java to Kotlin 2.0

Creating an Uber Clone - Part XXXII.pdf
Creating an Uber Clone - Part XXXII.pdfCreating an Uber Clone - Part XXXII.pdf
Creating an Uber Clone - Part XXXII.pdfShaiAlmog1
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroidConTLV
 
Michał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesMichał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesRST Software Masters
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011PayPal
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)RichardWarburton
 
Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Codemotion
 
Native Payment - Part 3.pdf
Native Payment - Part 3.pdfNative Payment - Part 3.pdf
Native Payment - Part 3.pdfShaiAlmog1
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mockskenbot
 
How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2Hirokazu Nishi
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2eugenio pombi
 
assigemt calculater.docx
assigemt calculater.docxassigemt calculater.docx
assigemt calculater.docxzekfeker
 
Automatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method DeclarationsAutomatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method DeclarationsICSM 2010
 
MVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin WayMVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin WayZeyad Gasser
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_twTse-Ching Ho
 
Correcting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NETCorrecting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NETBrandon Minnick, MBA
 

Similar to Migrating our micro services from Java to Kotlin 2.0 (20)

Creating an Uber Clone - Part XXXII.pdf
Creating an Uber Clone - Part XXXII.pdfCreating an Uber Clone - Part XXXII.pdf
Creating an Uber Clone - Part XXXII.pdf
 
Droid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, KikDroid on Chain - Berry Ventura Lev, Kik
Droid on Chain - Berry Ventura Lev, Kik
 
Michał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processesMichał Kopacz: Ports and adapters architecture for business processes
Michał Kopacz: Ports and adapters architecture for business processes
 
Chekout demistified
Chekout demistifiedChekout demistified
Chekout demistified
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 
Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8Pragmatic Functional Refactoring with Java 8
Pragmatic Functional Refactoring with Java 8
 
Native Payment - Part 3.pdf
Native Payment - Part 3.pdfNative Payment - Part 3.pdf
Native Payment - Part 3.pdf
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mocks
 
How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
 
Qtp test
Qtp testQtp test
Qtp test
 
New Design of OneRing
New Design of OneRingNew Design of OneRing
New Design of OneRing
 
assigemt calculater.docx
assigemt calculater.docxassigemt calculater.docx
assigemt calculater.docx
 
Automatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method DeclarationsAutomatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method Declarations
 
Spring Transaction
Spring TransactionSpring Transaction
Spring Transaction
 
MVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin WayMVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin Way
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 
Correcting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NETCorrecting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NET
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Migrating our micro services from Java to Kotlin 2.0

  • 1. Migrating our micro services from Java to Kotlin Yet another awesome journey
  • 5. Why we migrated from Java to Kotlin 5
  • 7. Checked exceptions 7 public static void refundExcessMoney() throws ExternalPspFailureException { // try to refund money throw new ExternalPspFailureException(); } try { refundExcessMoney() } catch (ExternalPspFailureException e) { // log or rethrow }
  • 8. Single abstract method types 8 public interface Comparator<T> { public boolean compare(T a, T b); } public class PaymentComparator implements Comparator<PaymentInformation> { @Overwrite public boolean compare(PaymentInformation a, PaymentInformation b) { ... } }
  • 9. Wildcard-types 9 // use-site wildcard List<?> paymentRawTypes = new ArrayList<Integer>(); void original(List<Number> paymentRawTypes) { } void withWildcard(List<? extends Number> paymentRawTypes) { } // Kotlin use-site variance var paymentRawTypes = listOf(1, 2, 3)
  • 11. Null-safety 11 // non null-able var paymentInformationId: UUID = UUID.randomUUID() paymentInformationId = null // compilation error // null-able var paymentInformationId : UUID? = UUID.randomUUID() paymentInformationId = null // ok
  • 12. Extension functions 12 // Java List<OrderId> orderIds = new ArrayList( Arrays.asList(id1, id2, id3) ); return JsonUtils.toJson(orderIds); // Kotlin val orderIds = listOf(id1, id2, id3) return orderIds.toJson()
  • 13. Smart casts 13 // Java if (payment instanceof CreditCardPayment) { CreditCardPayment ccPayment = (CreditCardPayment) payment; return ccPayment.getCardHolder(); } // Kotlin if (payment is CreditCardPayment) { return payment.cardHolder }
  • 15. Payment capture flow 15 PAY FEED PSPOM write feed poll status request capture capture poll feed
  • 16. fun capturePayment() { val lastKnownEventId = feedsService.getLatestEventId() paymentService.capture() val feedStatus = getFeedStatus(lastKnownEventId) feedStatus.whenError { throw CreditCardCaptureException() } } Request capture 16
  • 17. Asynchronous feed reader 17 fun getFeedStatus(lastKnownEventId: UUID?): PaymentFeedStatus { return runBlocking { withTimeout(syncClientTimeout) { var paymentFeedEvent: PaymentFeedEvent? do { paymentFeedEvent = feedsService.getSuccessorEventFor(lastKnownEventId) delay(200) } while (paymentFeedEvent.isNull()) paymentFeedEvent?.getStatus() } } }
  • 19. What did we migrate 19
  • 20. How did we migrate 20 refactor to idiomatic Kotlin verify using tests fix invalid code automatic code conversion
  • 22. Switching to Kotlin frameworks 22  KTOR - asynchronous Kotlin web framework  Spring Boot - established Java web framework  Often less matured  Often less documented No need to forcefully use Kotlin libraries and frameworks
  • 24. Review 24  Challenge which we mastered as team  Migrating was worth the effort  Improved design and new focus on language  Quality of life update 10/10 would use Kotlin again
  • 25. A heads up 25  Test coverage is a must have  Consider your people and eco system  Consider language and framework maturity level  Amount of new things can be overwhelming
  • 26. Outlook 26  Establish Kotlin at METRONOM  Help others introduce Kotlin  Introduce more native Kotlin frameworks  Find new passionate developers
  • 27. Follow us on Twitter and Instagram @bjoernwendland @joinmetronomnow #METRONOMians #wearedevs19 #passion #ambition #purpose Hall A Booth A11

Editor's Notes

  1. About Metronom ‚The biggest software company you never heard about‘ METRO’s tech unit providing solutions to customers and employees 'Setting the pace in food an technology‘ About Metro German global diversified retail and wholesale/cash and carry group based in Düsseldorf
  2. About me Joined METRONOM last july as Full Stack Developer Became Kotlin Ambassador at METRONOM over the cause of the last year
  3. Reasoning behind migrating to Kotlin How to approach the task What we’ve learned in the process
  4. Why did we choose Kotlin? A developers curiosity Java 2.0 It is close enough to the previous eco system (JVM / Spring Boot/ PostgresDB) Justification: “Setting the pace in food and technology” About the design Started with Java microservices based on proprietary (yet open source) web framework Unhappy with Java’s design Feeling of being outdated and heavy Finally tipping the scale Google announcing Kotlin as officially supported for Android Level of maturity By now Kotlin became the suggested language for Android development
  5. Checked exceptions Single Abstract Method Types (SAM Types) Wildcard Types
  6. Benefit: compiler error if exception is not handled Disadvantage: laborious and results in harder to read code Kotlin has unchecked exceptions
  7. Lambda expressions are considered a SAM type and can be freely converted SAM Type not bad in general, but propper function types are prefered Kotlin has proper function types opposed to SAM-conversions
  8. Not explicit / lacking information Unsafe (needs casting) Can be confusing Kotlin has use-site variance without wildcards
  9. Null-safety support in Kotlin typing system Extension functions Smart casts Coroutines
  10. ATTENTION: Java libraries null-safety can not be infered
  11. ATTENTION: How to manage extension functions?
  12. Using Coroutines See how async code is composed in real world code
  13. runBlocking launches coroutine withTimeout keeps runtime in check and throws exception of needed Read new event Delay:programmer allowes code to be scheduled at this point Infinite loop And return value Still reads like sync code, but allowes to be yielded It handles waiting for a response very greaceful Safe against infinite loops
  14. Why did we choose Kotlin? A developers curiosity Java 2.0 It is close enough to the previous eco system (JVM / Spring Boot/ PostgresDB) Justification: “Setting the pace in food and technology” About the design Started with Java microservices based on proprietary (yet open source) web framework Unhappy with Java’s design Feeling of being outdated and heavy Finally tipping the scale Google announcing Kotlin as officially supported for Android Level of maturity By now Kotlin became the suggested language for Android development
  15. Structured process Intellij’s automatic code conversion for class Fix non compiling code / non translatable language constructs Refactor, even partially rewrite methods Verify correctness using unit tests Convert unit tests
  16. Migrate to Kotlin libraries Goal was a 100% Kotlin micro service Mockk, Asskertk, Klaxon, etc. Add a library / framework next to existing one Phase out previously used Java framework Goal was a 100% Kotlin micro service Spiked KTOR and Spring Boot We decided to use Spring Boot, because it is fully documented and it enforces the project structure KTOR not yet mature enough and lacks documentation also does not enforce a project structure Will be considered again, since it is more lightweight and has better performance
  17. Finally a look back And one ahead
  18. Disclaimer Does not only plly to Kotlin
  19. If anyone is looking for a new job and wants to work with Kotlin
  20. Structured process Intellij’s automatic code conversion for class Fix non compiling code / non translatable language constructs Refactor, even partially rewrite methods Verify correctness using unit tests Convert unit tests