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
Confident refactors
Search
Mehdi Lahmam B.
June 19, 2017
Technology
1
110
Confident refactors
Mehdi Lahmam B.
June 19, 2017
Tweet
Share
More Decks by Mehdi Lahmam B.
See All by Mehdi Lahmam B.
Possible to measure developer productivity?
mehlah
0
33
PG FDW FTW
mehlah
0
150
Product culture
mehlah
0
49
OpenAPI and AsyncAPI specifications as contracts
mehlah
0
640
Technical Debt
mehlah
1
280
Data informed growth
mehlah
0
200
Serverless Ruby and AWS Lambda
mehlah
0
160
Middleware all the things
mehlah
2
830
If only I knew this shit in college
mehlah
0
200
Other Decks in Technology
See All in Technology
Part1 GitHubってなんだろう?その1
tomokusaba
3
710
RubyKaigi NOC 近況 2025
sorah
1
540
AIとSREで「今」できること
honmarkhunt
3
720
コードや知識を組み込む / Incorporating Codes and Knowledge
ks91
PRO
0
170
kernelvm-brain-net
raspython3
0
450
3D生成AIのための画像生成
kosukeito
2
610
Global Azure2025(GitHub Copilot ハンズオン)
tomokusaba
2
690
ペアーズにおける評価ドリブンな AI Agent 開発のご紹介
fukubaka0825
9
2.4k
TanStack Start 技術選定の裏側 / Findy-Lunch-LT-TanStack-Start
iktakahiro
0
100
Twelve-Factor-Appから学ぶECS設計プラクティス/ECS practice for Twelve-Factor-App
ozawa
3
160
Azure Maps Visual in PowerBIで分析しよう
nakasho
0
210
Compose におけるパスワード自動入力とパスワード保存
tonionagauzzi
0
210
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Bash Introduction
62gerente
612
210k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
560
Code Review Best Practice
trishagee
67
18k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
A designer walks into a library…
pauljervisheath
205
24k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Music & Morning Musume
bryan
47
6.5k
Side Projects
sachag
453
42k
KATA
mclloyd
29
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Transcript
Confident Refactors
Mehdi Lahmam @mehlah
25kV Rails app, started in Feb 2009 Never rewritten 23k+
commits from 52 contributors
Ruby is a massively successful language!
Early success Making it easy to make new things
Later success Making it easy to maintain old things
Today, let’s refactor some legacy code
Today, let’s refactor some legacy code
Refactor - verb To change the design of code without
changing its observable behavior.
Refactor - verb To change in advance of a new
feature or bug fix, making the job easier.
Today, let’s refactor some legacy code
Legacy - noun Old code.
Legacy - noun Code without tests.
Legacy - noun Code that we don’t like.
Legacy - noun Code we don’t understand well enough to
change confidently.
Today, let’s refactor some legacy code
Refactoring is hard
Refactoring legacy code is very hard
Easy to accidentally break functionality
Legacy refactors feels unsafe
Legacy refactors are hard to sell
Business priority Cost / risks
Business priority Cost / risks New features
Business priority Cost / risks New features Bugs fixes
Business priority Cost / risks New features Bugs fixes Testing
Business priority Cost / risks New features Bug fixes Testing
Refactoring
Business priority Cost / risks New features Bug fixes Testing
Refactoring no selling needed easy to sell can often sell very hard to sell
Selling refactoring is hard ⏲ ⛔
Business priority Cost / risks Refactoring
Too much pressure ⏳ ⚒
Refactors are scary
What techniques we have? PDD - Pray Driven Development Fowler’s
refactoring book Characterization testing A/B testing, experiments
Refactors as surgeries
Refactors as surgeries Requires careful planning Follow a clear process
Multiple observations Flexible tools Things can get bloody
1. Plan 2. Cut 3. Record 4. Validate 5. Refactor
6. Verify 7. Compare 8. Fallback 9. Delete Clear process
None
None
None
Cut
Record
Validate ✅
Refactor <Insert magic here />
Verify
Compare ⚖
Fallback
Delete ✂
We dit it
We dit it Time to celebrate hard