Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How the right architecture can simplify migrati...

Nico Krijnen
September 20, 2022

How the right architecture can simplify migrating to Kotlin

Do you want to migrate your Java codebase to Kotlin, but are you not sure where to start? And how to do that in small steps? This talk shows you how architecture patterns like hexagonal, vertical slice, and domain driven design can enable you to do just that, while at the same time increasing your code quality!

Presented at: KotlinDevDay 2021

Nico Krijnen

September 20, 2022
Tweet

More Decks by Nico Krijnen

Other Decks in Programming

Transcript

  1. ✓ More modular ✓ Clear separation ✓ Swap implementations Architectural

    benefits Tradeoffs: ❌ Have to add abstractions ❌ Can be hard not to leak details in those abstractions
  2. Core with no dependencies ✓ Easy to test ✓ Easy

    to change ✓ Easy to reason about
  3. How does that help migrate to Kotlin? ✓ Isolate most

    important code ✓ Kotlin where it matters most ✓ Outside can remain Java ✓ Outside modules can be isolated from each other
  4. How does that help migrate to Kotlin? ✓ Isolate most

    important code ✓ Kotlin where it matters most ✓ Outside can remain Java ✓ Outside modules can be isolated from each other
  5. Architectural benefits ✓ Clear separation ✓ Isolated & modular ✓

    High cohesion ✓ Low coupling ✓ Minimise feature complexity
  6. Vertical slices make it easy to ✓ Keep a feature

    in your head ✓ Refactor code ✓ Understand usage ✓ Prevent coupling ✓ Take small steps ✓ Limit your blast radius
  7. How does that help migrate to Kotlin? ✓ Introduce Kotlin

    feature-by-feature ✓ Evolve architecture feature-by-feature ✓ Take small steps
  8. How does that help migrate to Kotlin? ✓ Easy to

    write in Kotlin ✓ Introduce them
 one at a time ✓ Take small steps
  9. Encapsulation makes it easy to ✓ Keep a feature in

    your head ✓ Refactor code ✓ Understand usage ✓ Freely change implementation ✓ Limit your blast radius ✓ Take small steps
  10. Tests And what if you have none... Hexagonal – Vertical

    Slice – Value Objects – Encapsulation – Tests
  11. Test suite quality Do not accept: ❌ Flakey tests ❌

    Slow tests ❌ Bad test isolation ❌ Missing assertions ❌ Testing implementation details
  12. How does Kotlin help with tests? Test code should: ✓

    Be readable ✓ Communicate intent of module Kotlin helps here through: ✓ Expressiveness ✓ DSL capabilities Write a failing test Make the test pass Refactor
  13. What if you have no tests? “Legacy Code is code

    without tests” Michael Feathers: Working Effectively with Legacy Code
  14. What if you have no tests? "There is only one

    way to eat an elephant: a bite at a time." understandlegacycode.com “Legacy Code is code without tests” Michael Feathers: Working Effectively with Legacy Code
  15. How the right architecture can Simplify migrating to Kotlin Take

    small steps Nico Krijnen @nicokrijnen nkrijnen nicokrijnen