Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Three Principles To Bring Your Legacy Code Into...
Search
Roland Weisleder
December 11, 2023
Programming
0
240
Three Principles To Bring Your Legacy Code Into the Future
Roland Weisleder
December 11, 2023
Tweet
Share
More Decks by Roland Weisleder
See All by Roland Weisleder
Unit Test Your Java Architecture With ArchUnit
rweisleder
0
480
Immer wieder die gleichen Fehler? Nicht mit ArchUnit!
rweisleder
0
280
Alles einsteigen! Einen eigenen Release Train mit Maven umsetzen
rweisleder
0
310
7 Tipps für eine verständliche Git-Historie
rweisleder
0
140
Other Decks in Programming
See All in Programming
奥深くて厄介な「改行」と仲良くなる20分
oguemon
1
530
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
220
ファインディ株式会社におけるMCP活用とサービス開発
starfish719
0
1.1k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
300
Ruby Parser progress report 2025
yui_knk
1
440
rage against annotate_predecessor
junk0612
0
170
Android 16 × Jetpack Composeで縦書きテキストエディタを作ろう / Vertical Text Editor with Compose on Android 16
cc4966
1
220
今から始めるClaude Code入門〜AIコーディングエージェントの歴史と導入〜
nokomoro3
0
150
ユーザーも開発者も悩ませない TV アプリ開発 ~Compose の内部実装から学ぶフォーカス制御~
taked137
0
170
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.8k
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
3
1.4k
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
420
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
Why Our Code Smells
bkeepers
PRO
339
57k
RailsConf 2023
tenderlove
30
1.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Making Projects Easy
brettharned
117
6.4k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
The Cult of Friendly URLs
andyhume
79
6.6k
The Language of Interfaces
destraynor
161
25k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Typedesign – Prime Four
hannesfritz
42
2.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Transcript
@Ro_Wei Roland Weisleder
[email protected]
Three Principles To Bring Your Legacy
Code Into the Future
About Me Independent Software Developer & Consultant Bringing Legacy Java
Systems Into the Future Spring Boot Trainer @ workshops.de Lecturer @ HTW Berlin in/roland-weisleder @rweisleder @Ro_Wei
[email protected]
What is Legacy Code?* • Still in production use •
Relies on outdated technologies • Has insufficient test coverage • Lacks adequate documentation • Expert knowledge unavailable *According to ChatGPT
Big Bang Rewrite? Too time-consuming
What to improve? What you work on anyway
Rewrite or Refactor? Rewrite only with test coverage
Old bugs need to be added to the rewritten system.
Source: https://martinfowler.com/bliki/StranglerFigApplication.html
How to increase test coverage? Add tests for current behavior
How to understand the current behavior?
Where to start?
Source: https://www.commitstrip.com/en/2016/03/03/its-not-working/
Analyze Stack Trace or Thread Dump Source: https://www.jetbrains.com/help/idea/analyzing-external-stacktraces.html
Call Hierarchy
Source: https://twitter.com/codewisdom/status/1154436195126009858
Understand Code
Scratch Refactoring • Learn through refactoring • Make experiments •
Revert everything
Source: https://www.morling.dev/blog/the-code-review-pyramid/
Document Code
Our code is self-documenting.
• What about the input format? • What about malformed
input? • What about null? • What about thrown exceptions?
• What about the return value? * don’t use double
for money…
Suddenly a wild Java update appears
Unit tests are our documentation.
Who has read the tests of their favorite language /
framework / library to understand how to use it?
None
None
not only Don‘t Repeat Yourself but also Documentation Reflects Implementation
Source: https://twitter.com/sweblogtweets/status/1249698475249467393
Test Code
What should I test? The documented behavior.
Use Descriptive Test Names
Concise Implementation Keep relevant stuff together, hide irrelevant stuff
I want to test private methods Private methods are independent
units in disguise. Extract, document and test.
I have to mock everything So the method does nothing
useful? Keep it simple, delete the method.
The code contains hard-to-mock dependencies Current Time Database External Systems
Declare dependencies as parameters vs vs
Declare dependencies as parameters vs
Separate Domain and Infrastructure to simplify testing
Clean Architecture
Code Coverage • Find untested code • Find dead code
Still doing Scratch Refactoring? Revert everything, except the tests. Congratulations!
Time for TDD.
Inverted TDD
Source: https://twitter.com/kentbeck/status/250733358307500032
Improve Code
Source: https://www.morling.dev/blog/the-code-review-pyramid/
Focus on clean APIs
Define Interfaces Input Process Output
Invalid objects …
… vs valid objects
What about null?
Primitive Obsession vs
Source: https://twitter.com/codewisdom/status/1154436195126009858
None
https://www.youtube.com/watch?v=OGZ1JkC-cQc
Key Takeaways Separate Domain and Infrastructure Documentation Reflects Implementation Input
Process Output
Bringing Legacy Code Into the Future Slides: speakerdeck.com/rweisleder Gilded Rose
Kata: github.com/emilybache/GildedRose-Refactoring-Kata Need help with your Legacy Code? Contact me!
[email protected]
in/roland-weisleder @rweisleder @Ro_Wei