SlideShare a Scribd company logo
Taming scary production code
that nobody wants to touch
Mike Clement
Founding Software Craftsman at Greater Sum
mike@softwareontheside.com
http://blog.softwareontheside.com
http://www.greatersum.com
Modernizing Legacy Code
Mike Clement
Founding Software Craftsman at Greater Sum
mike@softwareontheside.com
http://blog.softwareontheside.com
http://www.greatersum.com
What is Legacy Code?
Legacy code is code that we’ve gotten
from someone else.
Legacy code is code that we’ve gotten
from past-self.
A slang term for difficult-to-change code
that we don’t understand.
Legacy code is simply code without tests.
Code without tests is bad code.
Code without tests is bad code?
Code without tests is scary code.
Legacy code (code without tests) is scary
production code that nobody wants to
touch.
Photo by Yung Chang on Unsplash
Risk
Photo by Leio McLaren on Unsplash
To mitigate risk, we have to ask three
questions:
1. What changes do we have to make?
2. How will we know that we’ve done them correctly?
3. How will we know that we haven’t broken anything?
How much change can you afford if
changes are risky?
Is it more important for the software
system to work
OR
is it more important for the software
system to be easy to change?
“If you give me a program that does not work
but is easy to change, then I can make it work,
and keep it working as requirements change.
Therefore the program will remain continually
useful.”
Robert C. Martin
How do we keep software soft?
Legacy/Scary Code Dilemma
When we change code, we should have
tests in place.
To put tests in place, we often have to
change code.
Legacy Code Dilemma
When we change code, we should have
tests in place.
To put tests in place, we often have to
change code.
Low Risk Changes via
Core Refactorings
re·fac·tor·ing (noun):
a change made to the internal structure of
software… without changing its observable
behavior.
https://martinfowler.com/bliki/DefinitionOfRefactoring.html
Core Refactorings as CRUD
• Create: Introduce/Extract:
• Local Variable
• Method
• Parameter
• Field
• Read: (performed by the human; no refactoring needed)
• Update: Rename
• Delete: Inline:
• Local Variable
• Method
• Parameter
• Field
http://arlobelshee.com/the-core-6-refactorings/
Core Refactorings Demo
Rental Store Code
To mitigate risk, we have to ask three
questions:
1. What changes do we have to make?
2. How will we know that we’ve done them correctly?
3. How will we know that we haven’t broken anything?
Use your tools!
Preserving existing behavior is one of the
largest challenges in software development.
Photo by Ben Koorengevel on Unsplash
Taming scary production code that nobody wants to touch
Edit and Pray
Photo by Ian Espinosa on Unsplash
“Working with care”
Taming scary production code that nobody wants to touch
Cover and Modify
Taming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touch
Preserving existing behavior is one of the
largest challenges in software development.
Characterization Tests
char·ac·ter·i·za·tion (noun)
a description of the distinctive nature or
features of something.
Characterization tests
a means to protect existing behavior of legacy code
against unintended changes
Characterization tests
a means to describe (characterize) the actual
behavior of an existing piece of software
Taming scary production code that nobody wants to touch
Photo by Ksenia Makagonova on Unsplash
Do not check for “correctness”
Check for existing behavior
Don’t have to understand
ApprovalTests Show & Tell
An open source assertion/verification library to aid unit testing
Seams
A seam is a place where you can alter
behavior in your program without editing
in that place.
Method boundary
Taming scary production code that nobody wants to touch
“Peel” Demo
Inject your dependency
Taming scary production code that nobody wants to touch
“Slice” Show & Tell
https://twitter.com/kentbeck/status/250733358307500032?lang=en
Resources
• Working Effectively with Legacy Code by Michael Feathers
• Clean Architecture by Robert C. Martin
• Peel & Slice videos by Llewellyn Falco
• 6 Core Refactorings by Arlo Belshee
Mike Clement
• @mdclement
• mike@softwareontheside.com
• http://blog.softwareontheside.com
• https://github.com/mdclement
• Greater Sum
• @thegreatersum
• http://www.greatersum.com
• Software Craftsmanship Atlanta
• Find us on meetup.com
• Limited WIP Society Atlanta
• Find us on meetup.com

More Related Content

PDF
Mob Programming for Continuous Learning
Mike Clement
 
PPTX
Play to Learn: Agile Games with Cards and Dice
Mike Clement
 
PPTX
Software Craftsmanship and Agile Code Games
Mike Clement
 
PPTX
The Fundamentals of Continuous Software Design
Jeremy Miller
 
PPTX
Software Craftsmanship VS Software Engineering
Andy Maleh
 
PPTX
Code Katas Spring 2012
Mike Clement
 
PPTX
Large Scale Data Management
Thomas Miller
 
PPTX
Extreme programming
Javier Sánchez Rois
 
Mob Programming for Continuous Learning
Mike Clement
 
Play to Learn: Agile Games with Cards and Dice
Mike Clement
 
Software Craftsmanship and Agile Code Games
Mike Clement
 
The Fundamentals of Continuous Software Design
Jeremy Miller
 
Software Craftsmanship VS Software Engineering
Andy Maleh
 
Code Katas Spring 2012
Mike Clement
 
Large Scale Data Management
Thomas Miller
 
Extreme programming
Javier Sánchez Rois
 

What's hot (19)

PDF
Pair Programming (2014)
Peter Kofler
 
PDF
Hiring a developer: step by step debugging
Laurent Cerveau
 
PDF
Dancing for a product release
Laurent Cerveau
 
PPTX
2013 09-11 java zone - extreme programming live
Johannes Brodwall
 
KEY
Loosely Coupled Complexity - Unleash the power of your Domain Model with Comm...
Alberto Brandolini
 
PPT
User Stories
James Peckham
 
PPTX
Building an Awesome Engineering Culture
Uri Nativ
 
PPT
Best practices for agile design
Igor Moochnick
 
PPT
Arch factory - Agile Design: Best Practices
Igor Moochnick
 
PPTX
Emperors new clothes_digitalbarn_output_snakk
kevinjohngallagher
 
PPTX
Emperors new clothes - digitalbarn2012
kevinjohngallagher
 
PPTX
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
kevinjohngallagher
 
PPTX
A sweet taste of clean code and software design
Kfir Bloch
 
PPTX
The secrets of building a team that can do everything
Kfir Bloch
 
PPTX
Infochimps: How We Do It
temujin9
 
PPTX
Agile design pattern
Poppy Martono
 
PDF
How to Ace Your Scrum Master Interview
Pavel Dabrytski
 
PDF
eXtreme Programming
Artem Tabalin
 
PDF
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
jazoon13
 
Pair Programming (2014)
Peter Kofler
 
Hiring a developer: step by step debugging
Laurent Cerveau
 
Dancing for a product release
Laurent Cerveau
 
2013 09-11 java zone - extreme programming live
Johannes Brodwall
 
Loosely Coupled Complexity - Unleash the power of your Domain Model with Comm...
Alberto Brandolini
 
User Stories
James Peckham
 
Building an Awesome Engineering Culture
Uri Nativ
 
Best practices for agile design
Igor Moochnick
 
Arch factory - Agile Design: Best Practices
Igor Moochnick
 
Emperors new clothes_digitalbarn_output_snakk
kevinjohngallagher
 
Emperors new clothes - digitalbarn2012
kevinjohngallagher
 
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
kevinjohngallagher
 
A sweet taste of clean code and software design
Kfir Bloch
 
The secrets of building a team that can do everything
Kfir Bloch
 
Infochimps: How We Do It
temujin9
 
Agile design pattern
Poppy Martono
 
How to Ace Your Scrum Master Interview
Pavel Dabrytski
 
eXtreme Programming
Artem Tabalin
 
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
jazoon13
 
Ad

Similar to Taming scary production code that nobody wants to touch (20)

PDF
Refactoring legacy code
Pablo Neves Machado
 
PPTX
Agile Australia 2016 - Rescuing Legacy Software from Impending Doom
Jacques De Vos
 
PDF
Working Effectively with Legacy Code: Lessons in Practice
Amar Shah
 
PDF
Working effectively with legacy code chapter1
Hiroaki NAKADA
 
PDF
How To Handle Your Tech Debt Better - Sean Moir
Mike Harris
 
PPTX
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
PPTX
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
PPTX
Refactoring workshop
Itzik Saban
 
PPTX
Refactoring in Software Reengineering .pptx
itstehreem2830
 
PDF
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
Agile đây Vietnam
 
PDF
Workshop fight legacy code write unit test
Tung Nguyen Thanh
 
PPT
Getting Unstuck: Working with Legacy Code and Data
Cory Foy
 
PDF
The Power Of Refactoring (PHPCon Italia)
Stefan Koopmanschap
 
PPTX
Working Effectively with Legacy Code
Orbit One - We create coherence
 
PPTX
Working effectively with legacy codes
Ali Shariat
 
PDF
The Power Of Refactoring (php|tek 09)
Stefan Koopmanschap
 
PPTX
Refactor your code: when, why and how (revisited)
Nacho Cougil
 
PPTX
Refactoring, 2nd Edition
jexp
 
PDF
Software Craftsmanship
Manfredi Giordano
 
ODP
Legacycodeisfearadibolboaca 141120063356-conversion-gate01
Codecamp Romania
 
Refactoring legacy code
Pablo Neves Machado
 
Agile Australia 2016 - Rescuing Legacy Software from Impending Doom
Jacques De Vos
 
Working Effectively with Legacy Code: Lessons in Practice
Amar Shah
 
Working effectively with legacy code chapter1
Hiroaki NAKADA
 
How To Handle Your Tech Debt Better - Sean Moir
Mike Harris
 
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
Refactoring workshop
Itzik Saban
 
Refactoring in Software Reengineering .pptx
itstehreem2830
 
[XPday.vn] Legacy code workshop (at) [XP Day Vietnam 2015]
Agile đây Vietnam
 
Workshop fight legacy code write unit test
Tung Nguyen Thanh
 
Getting Unstuck: Working with Legacy Code and Data
Cory Foy
 
The Power Of Refactoring (PHPCon Italia)
Stefan Koopmanschap
 
Working Effectively with Legacy Code
Orbit One - We create coherence
 
Working effectively with legacy codes
Ali Shariat
 
The Power Of Refactoring (php|tek 09)
Stefan Koopmanschap
 
Refactor your code: when, why and how (revisited)
Nacho Cougil
 
Refactoring, 2nd Edition
jexp
 
Software Craftsmanship
Manfredi Giordano
 
Legacycodeisfearadibolboaca 141120063356-conversion-gate01
Codecamp Romania
 
Ad

More from Mike Clement (16)

PPTX
Collaboration Principles from Mob Programming
Mike Clement
 
PPTX
Focus on Flow: Lean Principles in Action
Mike Clement
 
PPTX
Develop your sense of code smell
Mike Clement
 
PPTX
Maps over Backlogs: User Story Mapping to Share the Big Picture
Mike Clement
 
PPTX
Escaping the Pitfalls of Software Product Development
Mike Clement
 
PPTX
Put the Tests Before the Code
Mike Clement
 
PPTX
The Quest for Continuous Delivery at Pluralsight
Mike Clement
 
PPTX
Thinking in F#
Mike Clement
 
PPTX
Transformation Priority Premise: TDD Test Order Matters
Mike Clement
 
PPTX
Power of Patterns: Refactoring to (or away from) Patterns
Mike Clement
 
PPTX
FizzBuzz Guided Kata
Mike Clement
 
PPTX
Linq (from the inside)
Mike Clement
 
PPTX
Bowling Game Kata in C# Adapted
Mike Clement
 
PPTX
Code Katas: Practicing Your Craft
Mike Clement
 
PPTX
Software Craftsmanship
Mike Clement
 
PPTX
Using Rhino Mocks for Effective Unit Testing
Mike Clement
 
Collaboration Principles from Mob Programming
Mike Clement
 
Focus on Flow: Lean Principles in Action
Mike Clement
 
Develop your sense of code smell
Mike Clement
 
Maps over Backlogs: User Story Mapping to Share the Big Picture
Mike Clement
 
Escaping the Pitfalls of Software Product Development
Mike Clement
 
Put the Tests Before the Code
Mike Clement
 
The Quest for Continuous Delivery at Pluralsight
Mike Clement
 
Thinking in F#
Mike Clement
 
Transformation Priority Premise: TDD Test Order Matters
Mike Clement
 
Power of Patterns: Refactoring to (or away from) Patterns
Mike Clement
 
FizzBuzz Guided Kata
Mike Clement
 
Linq (from the inside)
Mike Clement
 
Bowling Game Kata in C# Adapted
Mike Clement
 
Code Katas: Practicing Your Craft
Mike Clement
 
Software Craftsmanship
Mike Clement
 
Using Rhino Mocks for Effective Unit Testing
Mike Clement
 

Recently uploaded (20)

PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Presentation about variables and constant.pptx
safalsingh810
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Immersive experiences: what Pharo users do!
ESUG
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 

Taming scary production code that nobody wants to touch

Editor's Notes

  • #22: The Legacy Code Dilemma
  • #23: The Legacy Code Dilemma
  • #34: then you poke around further to make sure that you didn’t break anything. The poking around is essential. When you make your changes, you are hoping and praying that you’ll get them right, and you take extra time when you are done to make sure that you did.
  • #46: When we have tests that detect change, it is like having a vise around our code.
  • #54: Peel off the dependency
  • #59: for each desired change, make the change easy (warming: this may be hard), then make the easy change Kent Beck