SlideShare a Scribd company logo
Stop Fearing Legacy Code
Yaki Koren
Agile Coach
Yaki@agilesparks.com
052-6194449
I was told it’s good to start
a presentation with an
interesting personal story.
I have a personal story but
it’s not so interesting.
Many years ago I worked on
a Legacy system…
There was a specific area
that was prone to defects.
So I asked my manager to
refactor it. After 3 days of
refactoring there were no
more defects. Not very
interesting indeed.
4 |
In many software
organizations there are
these black holes in the
software.
5 |
Only a few dare to penetrate
these holes.
Legacy code is like a minefield
Others stay away as though
these were mine fields.
7 |
Method
Method
Method
Method
Database
External API
Globals/static methods
Parameters
Output
These black holes tend to
grow and grow. Usually a
very big method (hundreds
and thousands of lines, if
not more) with many
dependencies.
Fear Of Legacy Code Make US:
 Dependent on specific people for specific tasks
 Avoid the right solution
 Slow to react
 Not as agile as we would like to be
8 |
Can you afford to have this
in your organization?
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
9 |
Are the steps to handle
these black holes.
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
10 |
At the road
Before starting road works,
there’s a lot of work to be
done, to make it safe.
12 |
In Construction
Scaffolding takes time to
build. It doesn’t add value by
itself.
What is the effect of the safety rope?
Would she be able to climb
so high without the safety
rope?
14 |
What about software?
What is the software safety
net?
Manual Tests?
Manual tests are better than
nothing. But it takes time
and difficult to repeat.
Integration Tests?
Integration tests are
expensive. They take time to
run and when something
fails you start debugging
Unit tests!
 Quick
 Pin pointed
 Cheap
Unit tests are very cheap,
very quick and pin point the
problem when it fails.
However it requires
discipline.
Unit Tests
18 |
Arrange
Act
Assert
Unit tests are built of three
phases: arrange data, act
(do the job), assert that the
actual outcome is what was
expected
19 |
The answer I get from people
in organizations: “You’re
absolutely right. However our
code is like spaghetti, therefore
it is impossible to run unit
tests.”
20 |
Cannot
write
tests
Cannot
refactor
Write
bad
code
It is time to break this
vicious cycle!
21 |
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
22 |
So, what do we do with our
spaghetti code?
23 |
Method
Method
Method
Method
Database
External API
Globals/static methods
Parameters
Output
1. Wrap, extract
to Interface.2. Add it as a
parameter/ field etc.
3. Create a
fake (Stub,
Mock or
Spy) for
your tests.Use available tests (manual, Integration) and
IDE refactoring (when exist) to do this slowly
and safely
Subclass and
override the
method for
the test
We handle the dependencies
one by one
24 |
That’s a lot of work!
This is about technique, practice
and discipline.
25 |
It took some of us one day
to create a unit test for a
method that everyone were
afraid of in a startup.
26 |
Fixate the results
You don’t need a design
document to know how
should the method work.
You just need to make sure
it continues doing what it
already does.
Return on Investment
 Start real slow
 See benefits
 Decide how to continue
27 |
No big investment is required.
You just need to start. It won’t
take long until you need to
make a change in a place that
already has tests – that’s
something!
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
28 |
Once the safety net is there the
fun begins. Now it is time to
start refactoring
Code Smells
 Black sheep/Oddball solution
 conditional complexity (If-Else)
 Deodorant method
 Duplicated code
 Feature envy
 Inappropriate intimacy/Indecent
exposure
 Inefficient name
 Long method/Lost intent, Large
class
29 |
 Long parameter list
 Primitive obsession
 Side effect
 Solution sprawl
 Speculative generality
 Switch statement
 Temporary field
There are many instances of
bad code
Common Refactoring
 Rename
 Extract Method / Inline
 Move
 Extract Interface
30 |
Start with simple refactoring
Eclipse Refactoring/Generation Tools
31 |
Refactor menu
Quick fixes
Intellij Refactoring/Generation Tools
32 |
Alt + Enter on a name
Refactor menu
Suggestions
Visual Studio Refactoring/Generation
Tools
33 |
Refactor/Quick
actions menu
Quick Actions
Refactoring To Patterns: Small Steps (2 Min.)
34 |
Use design patterns to make the
system more robust, easier to
change
35 |
Every two minutes:
• Make a small change, test
• Make a small change, test
• Make a small change, test
• Make a small change, test
• Make a small change, test
• Make a small change, test
• Stop any time, move to another task. Go home
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
36 |
With the safety net there and
with the code readable and
easy to change, making a
change is easy
Test Driven Design
 Write a test to make sure what you want to move
 Make the test fail
 Make it pass
 Refator
37 |
Ending The Fear Of Legacy Code
 Understand what is our safety net
 Weave the safety net
 Make it easy to understand and change
 Make the change
38 |
Thanks!
Yaki Koren
Agile Coach
Yaki@agilesparks.com
052-6194449

More Related Content

What's hot

Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
Trisha Gee
 
Testing strategies for legacy code
Testing strategies for legacy codeTesting strategies for legacy code
Testing strategies for legacy code
Alex Soto
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
Steven Smith
 
A Taste of Exploratory Testing
A Taste of Exploratory TestingA Taste of Exploratory Testing
A Taste of Exploratory Testing
Anne-Marie Charrett
 
Exploratory testing STEW 2016
Exploratory testing STEW 2016Exploratory testing STEW 2016
Exploratory testing STEW 2016
Per Runeson
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
Alexandru Bolboaca
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
catherinewall
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
Trisha Gee
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
Siriwat Jithunsa
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
Michael Denomy
 
Simple testable code
Simple testable codeSimple testable code
Simple testable code
felixtrepanier
 
A taste of Exploratory Testing
A taste of Exploratory TestingA taste of Exploratory Testing
A taste of Exploratory Testing
Anne-Marie Charrett
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
Coverity
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
Amir Assad
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
Peter Presnell
 
Exploratory Testing in Practice
Exploratory Testing in PracticeExploratory Testing in Practice
Exploratory Testing in Practice
Elisabeth Hendrickson
 
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code QualityITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
ITCamp
 
iHale Milestone 1 Feedback
iHale Milestone 1 FeedbackiHale Milestone 1 Feedback
iHale Milestone 1 Feedback
Philip Johnson
 
Industry-Academia Communication In Empirical Software Engineering
Industry-Academia Communication In Empirical Software EngineeringIndustry-Academia Communication In Empirical Software Engineering
Industry-Academia Communication In Empirical Software Engineering
Per Runeson
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
guy_davis
 

What's hot (20)

Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
 
Testing strategies for legacy code
Testing strategies for legacy codeTesting strategies for legacy code
Testing strategies for legacy code
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
 
A Taste of Exploratory Testing
A Taste of Exploratory TestingA Taste of Exploratory Testing
A Taste of Exploratory Testing
 
Exploratory testing STEW 2016
Exploratory testing STEW 2016Exploratory testing STEW 2016
Exploratory testing STEW 2016
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
 
Pair Programming
Pair ProgrammingPair Programming
Pair Programming
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Simple testable code
Simple testable codeSimple testable code
Simple testable code
 
A taste of Exploratory Testing
A taste of Exploratory TestingA taste of Exploratory Testing
A taste of Exploratory Testing
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
 
Exploratory Testing in Practice
Exploratory Testing in PracticeExploratory Testing in Practice
Exploratory Testing in Practice
 
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code QualityITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
ITCamp 2013 - Florin Coros - Driving Your Team Towards Code Quality
 
iHale Milestone 1 Feedback
iHale Milestone 1 FeedbackiHale Milestone 1 Feedback
iHale Milestone 1 Feedback
 
Industry-Academia Communication In Empirical Software Engineering
Industry-Academia Communication In Empirical Software EngineeringIndustry-Academia Communication In Empirical Software Engineering
Industry-Academia Communication In Empirical Software Engineering
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

Similar to Stop fearing legacy code

Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy Code
Eyal Golan
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
cobyst
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
Itzik Saban
 
Code Smells Part 1: Basic Smells
Code Smells Part 1:  Basic SmellsCode Smells Part 1:  Basic Smells
Code Smells Part 1: Basic Smells
Nancy Henson
 
From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018
Christophe Rochefolle
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
Paulo Clavijo
 
Test driven development
Test driven developmentTest driven development
Test driven development
Sunil Prasad
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
Mainframes agile2012
Mainframes agile2012Mainframes agile2012
Mainframes agile2012
drewz lin
 
Debugging
DebuggingDebugging
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
BlackRabbitCoder
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First Example
Vorleak Chy
 
Refactoring ASP.NET and beyond
Refactoring ASP.NET and beyondRefactoring ASP.NET and beyond
Refactoring ASP.NET and beyond
DotNetMarche
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
Giorgio Zoppi
 
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesHow to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
Christian Beedgen
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
Bill Buchan
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
Alex Borsuk
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
TobiasGoeschel
 
Software craftsmanship and you a strong foundation in your team
Software craftsmanship and you a strong foundation in your teamSoftware craftsmanship and you a strong foundation in your team
Software craftsmanship and you a strong foundation in your team
Dattatray Kale
 
Improve existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit testsImprove existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit tests
Dattatray Kale
 

Similar to Stop fearing legacy code (20)

Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy Code
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Code Smells Part 1: Basic Smells
Code Smells Part 1:  Basic SmellsCode Smells Part 1:  Basic Smells
Code Smells Part 1: Basic Smells
 
From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
Mainframes agile2012
Mainframes agile2012Mainframes agile2012
Mainframes agile2012
 
Debugging
DebuggingDebugging
Debugging
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First Example
 
Refactoring ASP.NET and beyond
Refactoring ASP.NET and beyondRefactoring ASP.NET and beyond
Refactoring ASP.NET and beyond
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesHow to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
Software craftsmanship and you a strong foundation in your team
Software craftsmanship and you a strong foundation in your teamSoftware craftsmanship and you a strong foundation in your team
Software craftsmanship and you a strong foundation in your team
 
Improve existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit testsImprove existing code with confidence, supported by unit tests
Improve existing code with confidence, supported by unit tests
 

More from Yaki Koren

Software development team work!
Software development team work!Software development team work!
Software development team work!
Yaki Koren
 
Handling Waterfall Nostalgia when Moving to Agile
Handling Waterfall Nostalgia when Moving to AgileHandling Waterfall Nostalgia when Moving to Agile
Handling Waterfall Nostalgia when Moving to Agile
Yaki Koren
 
Manager's role in an agile implementation
Manager's role in an agile implementationManager's role in an agile implementation
Manager's role in an agile implementation
Yaki Koren
 
Scrum Mass Training
Scrum Mass TrainingScrum Mass Training
Scrum Mass Training
Yaki Koren
 
Scrum: an old tale and a despicable overview
Scrum: an old tale and a despicable overviewScrum: an old tale and a despicable overview
Scrum: an old tale and a despicable overview
Yaki Koren
 
Amdocs Case Study: Massive Kanban Implementation (LKNA14)
Amdocs Case Study: Massive Kanban Implementation (LKNA14)Amdocs Case Study: Massive Kanban Implementation (LKNA14)
Amdocs Case Study: Massive Kanban Implementation (LKNA14)
Yaki Koren
 
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocs
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocsGoodbye scope anxiety hello agility: Kanban implementation case study at amdocs
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocs
Yaki Koren
 

More from Yaki Koren (7)

Software development team work!
Software development team work!Software development team work!
Software development team work!
 
Handling Waterfall Nostalgia when Moving to Agile
Handling Waterfall Nostalgia when Moving to AgileHandling Waterfall Nostalgia when Moving to Agile
Handling Waterfall Nostalgia when Moving to Agile
 
Manager's role in an agile implementation
Manager's role in an agile implementationManager's role in an agile implementation
Manager's role in an agile implementation
 
Scrum Mass Training
Scrum Mass TrainingScrum Mass Training
Scrum Mass Training
 
Scrum: an old tale and a despicable overview
Scrum: an old tale and a despicable overviewScrum: an old tale and a despicable overview
Scrum: an old tale and a despicable overview
 
Amdocs Case Study: Massive Kanban Implementation (LKNA14)
Amdocs Case Study: Massive Kanban Implementation (LKNA14)Amdocs Case Study: Massive Kanban Implementation (LKNA14)
Amdocs Case Study: Massive Kanban Implementation (LKNA14)
 
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocs
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocsGoodbye scope anxiety hello agility: Kanban implementation case study at amdocs
Goodbye scope anxiety hello agility: Kanban implementation case study at amdocs
 

Recently uploaded

Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 

Recently uploaded (20)

Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 

Stop fearing legacy code

  • 1. Stop Fearing Legacy Code Yaki Koren Agile Coach Yaki@agilesparks.com 052-6194449
  • 2. I was told it’s good to start a presentation with an interesting personal story. I have a personal story but it’s not so interesting. Many years ago I worked on a Legacy system…
  • 3. There was a specific area that was prone to defects. So I asked my manager to refactor it. After 3 days of refactoring there were no more defects. Not very interesting indeed.
  • 4. 4 | In many software organizations there are these black holes in the software.
  • 5. 5 | Only a few dare to penetrate these holes.
  • 6. Legacy code is like a minefield Others stay away as though these were mine fields.
  • 7. 7 | Method Method Method Method Database External API Globals/static methods Parameters Output These black holes tend to grow and grow. Usually a very big method (hundreds and thousands of lines, if not more) with many dependencies.
  • 8. Fear Of Legacy Code Make US:  Dependent on specific people for specific tasks  Avoid the right solution  Slow to react  Not as agile as we would like to be 8 | Can you afford to have this in your organization?
  • 9. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 9 | Are the steps to handle these black holes.
  • 10. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 10 |
  • 11. At the road Before starting road works, there’s a lot of work to be done, to make it safe.
  • 12. 12 | In Construction Scaffolding takes time to build. It doesn’t add value by itself.
  • 13. What is the effect of the safety rope? Would she be able to climb so high without the safety rope?
  • 14. 14 | What about software? What is the software safety net?
  • 15. Manual Tests? Manual tests are better than nothing. But it takes time and difficult to repeat.
  • 16. Integration Tests? Integration tests are expensive. They take time to run and when something fails you start debugging
  • 17. Unit tests!  Quick  Pin pointed  Cheap Unit tests are very cheap, very quick and pin point the problem when it fails. However it requires discipline.
  • 18. Unit Tests 18 | Arrange Act Assert Unit tests are built of three phases: arrange data, act (do the job), assert that the actual outcome is what was expected
  • 19. 19 | The answer I get from people in organizations: “You’re absolutely right. However our code is like spaghetti, therefore it is impossible to run unit tests.”
  • 21. 21 |
  • 22. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 22 | So, what do we do with our spaghetti code?
  • 23. 23 | Method Method Method Method Database External API Globals/static methods Parameters Output 1. Wrap, extract to Interface.2. Add it as a parameter/ field etc. 3. Create a fake (Stub, Mock or Spy) for your tests.Use available tests (manual, Integration) and IDE refactoring (when exist) to do this slowly and safely Subclass and override the method for the test We handle the dependencies one by one
  • 24. 24 | That’s a lot of work! This is about technique, practice and discipline.
  • 25. 25 | It took some of us one day to create a unit test for a method that everyone were afraid of in a startup.
  • 26. 26 | Fixate the results You don’t need a design document to know how should the method work. You just need to make sure it continues doing what it already does.
  • 27. Return on Investment  Start real slow  See benefits  Decide how to continue 27 | No big investment is required. You just need to start. It won’t take long until you need to make a change in a place that already has tests – that’s something!
  • 28. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 28 | Once the safety net is there the fun begins. Now it is time to start refactoring
  • 29. Code Smells  Black sheep/Oddball solution  conditional complexity (If-Else)  Deodorant method  Duplicated code  Feature envy  Inappropriate intimacy/Indecent exposure  Inefficient name  Long method/Lost intent, Large class 29 |  Long parameter list  Primitive obsession  Side effect  Solution sprawl  Speculative generality  Switch statement  Temporary field There are many instances of bad code
  • 30. Common Refactoring  Rename  Extract Method / Inline  Move  Extract Interface 30 | Start with simple refactoring
  • 31. Eclipse Refactoring/Generation Tools 31 | Refactor menu Quick fixes
  • 32. Intellij Refactoring/Generation Tools 32 | Alt + Enter on a name Refactor menu Suggestions
  • 33. Visual Studio Refactoring/Generation Tools 33 | Refactor/Quick actions menu Quick Actions
  • 34. Refactoring To Patterns: Small Steps (2 Min.) 34 | Use design patterns to make the system more robust, easier to change
  • 35. 35 | Every two minutes: • Make a small change, test • Make a small change, test • Make a small change, test • Make a small change, test • Make a small change, test • Make a small change, test • Stop any time, move to another task. Go home
  • 36. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 36 | With the safety net there and with the code readable and easy to change, making a change is easy
  • 37. Test Driven Design  Write a test to make sure what you want to move  Make the test fail  Make it pass  Refator 37 |
  • 38. Ending The Fear Of Legacy Code  Understand what is our safety net  Weave the safety net  Make it easy to understand and change  Make the change 38 |