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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Roland Weisleder
December 11, 2023
Programming
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Enforcing Architecture in Legacy Systems
rweisleder
0
3
Architecture as Code in Practice
rweisleder
0
33
Unit Test Your Java Architecture With ArchUnit
rweisleder
0
580
Immer wieder die gleichen Fehler? Nicht mit ArchUnit!
rweisleder
0
370
Alles einsteigen! Einen eigenen Release Train mit Maven umsetzen
rweisleder
0
350
7 Tipps für eine verständliche Git-Historie
rweisleder
0
180
Other Decks in Programming
See All in Programming
AI 輔助遺留系統現代化的經驗分享
jame2408
1
990
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
100
Webフレームワークの ベンチマークについて
yusukebe
0
180
Oxlintのカスタムルールの現況
syumai
6
1.2k
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
610
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
ふつうのFeature Flag実践入門
irof
8
4.2k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
2
760
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
330
The SEO identity crisis: Don't let AI make you average
varn
0
500
sira's awesome portfolio website redesign presentation
elsirapls
0
280
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Building Flexible Design Systems
yeseniaperezcruz
330
40k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
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