✓ More modular
✓ Clear separation
✓ Swap implementations
Architectural benefits
Tradeoffs:
❌ Have to add abstractions
❌ Can be hard not to leak
details in those abstractions
Slide 33
Slide 33 text
Core with no dependencies
✓ Easy to test
✓ Easy to change
✓ Easy to reason about
Slide 34
Slide 34 text
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
Slide 35
Slide 35 text
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
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
Slide 43
Slide 43 text
How does that help migrate to Kotlin?
✓ Introduce Kotlin
feature-by-feature
✓ Evolve architecture
feature-by-feature
✓ Take small steps
Slide 44
Slide 44 text
Techniques
Value objects
Hexagonal – Vertical Slice – Value Objects – Encapsulation – Tests
Slide 45
Slide 45 text
Value objects
Slide 46
Slide 46 text
Value objects
Slide 47
Slide 47 text
Value objects
Slide 48
Slide 48 text
Validation
Slide 49
Slide 49 text
Value objects
Slide 50
Slide 50 text
(De)Serialization
Slide 51
Slide 51 text
How does that help
migrate to Kotlin?
✓ Easy to write in Kotlin
✓ Introduce them
one at a time
✓ Take small steps
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
Slide 58
Slide 58 text
Tests
And what if you have none...
Hexagonal – Vertical Slice – Value Objects – Encapsulation – Tests
Slide 59
Slide 59 text
Test suite quality
Do not accept:
❌ Flakey tests
❌ Slow tests
❌ Bad test isolation
❌ Missing assertions
❌ Testing implementation details
Slide 60
Slide 60 text
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
Slide 61
Slide 61 text
What about the old tests?
Slide 62
Slide 62 text
What if you have no tests?
“Legacy Code is code without tests”
Michael Feathers: Working Effectively with Legacy Code
Slide 63
Slide 63 text
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
Slide 64
Slide 64 text
Techniques
Hexagonal
Vertical slice
Value objects
Encapsulation Tests
Slide 65
Slide 65 text
Take small steps
Slide 66
Slide 66 text
How the right architecture can
Simplify migrating to Kotlin
Take small steps
Nico Krijnen
@nicokrijnen nkrijnen nicokrijnen