Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
140
Confident refactors
Mehdi Lahmam B.
June 19, 2017
Tweet
Share
More Decks by Mehdi Lahmam B.
See All by Mehdi Lahmam B.
Beyond code: Becoming a Product Engineer
mehlah
0
36
Possible to measure developer productivity?
mehlah
0
45
PG FDW FTW
mehlah
0
170
Product culture
mehlah
0
74
OpenAPI and AsyncAPI specifications as contracts
mehlah
0
670
Technical Debt
mehlah
1
290
Data informed growth
mehlah
0
240
Serverless Ruby and AWS Lambda
mehlah
0
170
Middleware all the things
mehlah
2
860
Other Decks in Technology
See All in Technology
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
110
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
260
Uncertainty in the LLM era - Science, more than scale
gaelvaroquaux
0
820
新 Security HubがついにGA!仕組みや料金を深堀り #AWSreInvent #regrowth / AWS Security Hub Advanced GA
masahirokawahara
1
1.6k
手動から自動へ、そしてその先へ
moritamasami
0
290
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
460
ML PM Talk #1 - ML PMの分類に関する考察
lycorptech_jp
PRO
1
750
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
530
エンジニアとPMのドメイン知識の溝をなくす、 AIネイティブな開発プロセス
applism118
4
1.1k
EM歴1年10ヶ月のぼくがぶち当たった苦悩とこれからへ向けて
maaaato
0
270
AWSを使う上で最低限知っておきたいセキュリティ研修を社内で実施した話 ~みんなでやるセキュリティ~
maimyyym
2
220
Karate+Database RiderによるAPI自動テスト導入工数をCline+GitLab MCPを使って2割削減を目指す! / 20251206 Kazuki Takahashi
shift_evolve
PRO
1
600
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Writing Fast Ruby
sferik
630
62k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
How to train your dragon (web standard)
notwaldorf
97
6.4k
Designing for Performance
lara
610
69k
Building Adaptive Systems
keathley
44
2.9k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Designing Experiences People Love
moore
143
24k
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