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
250
0
Share
Three Principles To Bring Your Legacy Code Into the Future
Roland Weisleder
December 11, 2023
More Decks by Roland Weisleder
See All by Roland Weisleder
Architecture as Code in Practice
rweisleder
0
31
Unit Test Your Java Architecture With ArchUnit
rweisleder
0
570
Immer wieder die gleichen Fehler? Nicht mit ArchUnit!
rweisleder
0
360
Alles einsteigen! Einen eigenen Release Train mit Maven umsetzen
rweisleder
0
340
7 Tipps für eine verständliche Git-Historie
rweisleder
0
180
Other Decks in Programming
See All in Programming
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
280
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
410
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
200
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
🦞OpenClaw works with AWS
licux
1
350
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
150
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
GoogleCloudとterraform完全に理解した
terisuke
1
200
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
140
[RubyKaigi 2026] Require Hooks
palkan
1
320
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
7
640
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
170
Fireside Chat
paigeccino
42
3.9k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
Abbi's Birthday
coloredviolet
2
7.6k
We Have a Design System, Now What?
morganepeng
55
8.1k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
370
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
290
Building Applications with DynamoDB
mza
96
7k
A Tale of Four Properties
chriscoyier
163
24k
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