Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
99
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
24
PG FDW FTW
mehlah
0
140
Product culture
mehlah
0
38
OpenAPI and AsyncAPI specifications as contracts
mehlah
0
630
Technical Debt
mehlah
1
260
Data informed growth
mehlah
0
190
Serverless Ruby and AWS Lambda
mehlah
0
140
Middleware all the things
mehlah
2
820
If only I knew this shit in college
mehlah
0
190
Other Decks in Technology
See All in Technology
AWS re:Invent 2024 予選落ちのBedrockアプデをまとめて解説!
minorun365
PRO
2
240
Amazon CloudFrontを活用したゼロダウンタイム実現する安定的なデプロイメント / 20241129 Yoshiki Shinagawa
shift_evolve
0
140
【CNDW2024】SIerで200人クラウドネイティブのファンを増やした話
yuta1979
1
310
マルチプロダクト、マルチデータ基盤での Looker活用事例 〜BQじゃなくてもLookerはいいぞ〜
gappy50
0
130
ドメインロジックで考えるテスタビリティ
leveragestech
1
270
Hyperledger Fabric(再)入門
gakumura
3
6.7k
リモートだからこそ 懸念だし1on1
jimpei
2
380
乗っ取れKubernetes!!~リスクから学ぶKubernetesセキュリティの考え方~/k8s-risk-and-security
mochizuki875
3
450
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
150
お悩みハンドブック紹介資料
grafferhandbook
0
410
Explain EXPLAIN
keiko713
2
400
農業用ダム監視を目的とした衛星SAR 干渉解析の適用性について
osgeojp
0
130
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
770
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Rails Girls Zürich Keynote
gr2m
94
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Agile that works and the tools we love
rasmusluckow
327
21k
[RailsConf 2023] Rails as a piece of cake
palkan
52
5k
BBQ
matthewcrist
85
9.3k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
The Cost Of JavaScript in 2023
addyosmani
45
6.9k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Happy Clients
brianwarren
98
6.7k
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