SlideShare ist ein Scribd-Unternehmen logo
1 von 39
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

Weitere Àhnliche Inhalte

Was ist angesagt?

Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated TestsTrisha Gee
 
Testing strategies for legacy code
Testing strategies for legacy codeTesting strategies for legacy code
Testing strategies for legacy codeAlex Soto
 
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsCinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patternsSteven Smith
 
A Taste of Exploratory Testing
A Taste of Exploratory TestingA Taste of Exploratory Testing
A Taste of Exploratory TestingAnne-Marie Charrett
 
Exploratory testing STEW 2016
Exploratory testing STEW 2016Exploratory testing STEW 2016
Exploratory testing STEW 2016Per Runeson
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTscatherinewall
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated TestsTrisha Gee
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 
Simple testable code
Simple testable codeSimple testable code
Simple testable codefelixtrepanier
 
A taste of Exploratory Testing
A taste of Exploratory TestingA taste of Exploratory Testing
A taste of Exploratory TestingAnne-Marie Charrett
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting AgileCoverity
 
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 TestingPeter Presnell
 
Exploratory Testing in Practice
Exploratory Testing in PracticeExploratory Testing in Practice
Exploratory Testing in PracticeElisabeth 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 QualityITCamp
 
iHale Milestone 1 Feedback
iHale Milestone 1 FeedbackiHale Milestone 1 Feedback
iHale Milestone 1 FeedbackPhilip 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 EngineeringPer Runeson
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguy_davis
 

Was ist angesagt? (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
 

Ähnlich wie Stop fearing legacy code

Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy CodeEyal Golan
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
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 SmellsNancy 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 2018Christophe 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 2019Paulo Clavijo
 
Test driven development
Test driven developmentTest driven development
Test driven developmentSunil 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 agile2012drewz lin
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of OptimizationBlackRabbitCoder
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First ExampleVorleak Chy
 
Refactoring ASP.NET and beyond
Refactoring ASP.NET and beyondRefactoring ASP.NET and beyond
Refactoring ASP.NET and beyondDotNetMarche
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software DesignGiorgio 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 ServicesChristian Beedgen
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill 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.pdfTobiasGoeschel
 
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 teamDattatray 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 testsDattatray Kale
 

Ähnlich wie 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
 

Mehr von 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 AgileYaki 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 implementationYaki Koren
 
Scrum Mass Training
Scrum Mass TrainingScrum Mass Training
Scrum Mass TrainingYaki 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 overviewYaki 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 amdocsYaki Koren
 

Mehr von 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
 

KĂŒrzlich hochgeladen

Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzĂĄlez Trastoy
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

KĂŒrzlich hochgeladen (20)

Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

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 |