SlideShare uma empresa Scribd logo
1 de 11
Testing and Refactoring
Legacy Code
Sandro Mancuso
@sandromancuso
craftedsw.blogspot.com
What is this session about?
Business Requirements
Imagine a social networking website for
travellers
• You need to be logged in to see the content
• You need to be a friend to see someone else’s
trips
Legacy Code Rules
• You cannot change production code if not
covered by tests
– Just automated refactoring (via IDE) is allowed, in
case it is needed for writing a test
Show me the code
Start refactoring from
deepest to shortest
branch
Start testing from
shortest to
deepest branch
Working with Legacy Code Tips
Trip Service - Problems
TripService
+findTripsByUser(User) : List<Trip>
<<Singleton>>
UserSession
+getInstance() : UserSession
+getLoggedUser() : User
TripDAO
+findTripsByUser(User) : List<Trip>
Let’s write some code
Start refactoring from
deepest to shortest
branch
Start testing from
shortest to
deepest branch
Working with Legacy Code Tips
Craftsmen at work
• Write readable and maintainable code and tests
– Code must express business rules
• Strive for simplicity
• Know your tools well (i.e. frameworks, shortcuts)
• Work in small and safe increments
– Commit often
• Embrace changes, be brave
• Boy scout rule / No broken windows
Thanks
Sandro Mancuso
@sandromancuso
craftedsw.blogspot.com
https://github.com/sandromancuso/trip-service-kata
leanpub.com/socra

Mais conteúdo relacionado

Mais procurados

Mais procurados (11)

Boost your App with Gatling
Boost your App with GatlingBoost your App with Gatling
Boost your App with Gatling
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
]project-open[ Workflow Developer Tutorial Part 2
]project-open[ Workflow Developer Tutorial Part 2]project-open[ Workflow Developer Tutorial Part 2
]project-open[ Workflow Developer Tutorial Part 2
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shift
 
Intro to TDD and BDD
Intro to TDD and BDDIntro to TDD and BDD
Intro to TDD and BDD
 
]project-open[ Workflow Developer Tutorial Part 1
]project-open[ Workflow Developer Tutorial Part 1]project-open[ Workflow Developer Tutorial Part 1
]project-open[ Workflow Developer Tutorial Part 1
 
Continuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatlingContinuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatling
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 

Destaque

Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
Samir Talwar
 
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
Radu Marinescu
 
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, BucharestSandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
Mozaic Works
 
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
Mozaic Works
 

Destaque (6)

Unit testing-patterns
Unit testing-patternsUnit testing-patterns
Unit testing-patterns
 
Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
 
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
The Good the Bad and the Ugly of Dealing with Smelly Code (ITAKE Unconference)
 
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, BucharestSandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
Sandro Mancuso - Software Craftmanship @ I T.A.K.E. Unconference 2013, Bucharest
 
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
Erik talboom - TDD as if The Baby Meant it @I T.A.K.E. Unconference 2013, Buc...
 
I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"
 

Semelhante a Sandro Mancuso – Testing and refactoring legacy code @ I T.A.K.E. Unconference 2013, Bucharest

Code Review
Code ReviewCode Review
Code Review
Ravi Raj
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 

Semelhante a Sandro Mancuso – Testing and refactoring legacy code @ I T.A.K.E. Unconference 2013, Bucharest (20)

Legacy Code Hands-on Session
Legacy Code Hands-on Session Legacy Code Hands-on Session
Legacy Code Hands-on Session
 
Code Review
Code ReviewCode Review
Code Review
 
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar SinghWorkshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
Refactoring ASP.NET and beyond
Refactoring ASP.NET and beyondRefactoring ASP.NET and beyond
Refactoring ASP.NET and beyond
 
Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NET
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Make xCommerce fit to you
Make xCommerce fit to youMake xCommerce fit to you
Make xCommerce fit to you
 
Refactoring to Testable Code
Refactoring to Testable CodeRefactoring to Testable Code
Refactoring to Testable Code
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
Enhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code ContractsEnhance Your Code Quality with Code Contracts
Enhance Your Code Quality with Code Contracts
 
TDD
TDDTDD
TDD
 
Scrum and BDD for Developers with Naveen Kumar
Scrum and BDD for Developers with Naveen Kumar Scrum and BDD for Developers with Naveen Kumar
Scrum and BDD for Developers with Naveen Kumar
 
Approaching ATDD/BDD
Approaching ATDD/BDDApproaching ATDD/BDD
Approaching ATDD/BDD
 
Gateway to Agile: XP and BDD
Gateway to Agile: XP and BDD Gateway to Agile: XP and BDD
Gateway to Agile: XP and BDD
 
Rapid app building with loopback framework
Rapid app building with loopback frameworkRapid app building with loopback framework
Rapid app building with loopback framework
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
 

Mais de Mozaic Works

Mais de Mozaic Works (20)

Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile Retrospectives
 
Developer Experience to Testing
Developer Experience to TestingDeveloper Experience to Testing
Developer Experience to Testing
 
Story mapping: build better products with a happier team
Story mapping: build better products with a happier teamStory mapping: build better products with a happier team
Story mapping: build better products with a happier team
 
Andrea Mocci: Beautiful Design, Beautiful Coding at I T.A.K.E. Unconference 2015
Andrea Mocci: Beautiful Design, Beautiful Coding at I T.A.K.E. Unconference 2015Andrea Mocci: Beautiful Design, Beautiful Coding at I T.A.K.E. Unconference 2015
Andrea Mocci: Beautiful Design, Beautiful Coding at I T.A.K.E. Unconference 2015
 
Ionuț G. Stan - Let’s write a type checker at I T.A.K.E. Unconference 2015
Ionuț G. Stan - Let’s write a type checker at I T.A.K.E. Unconference 2015Ionuț G. Stan - Let’s write a type checker at I T.A.K.E. Unconference 2015
Ionuț G. Stan - Let’s write a type checker at I T.A.K.E. Unconference 2015
 
Cyrille Martraire: Living Documentation Jumpstart at I T.A.K.E. Unconference ...
Cyrille Martraire: Living Documentation Jumpstart at I T.A.K.E. Unconference ...Cyrille Martraire: Living Documentation Jumpstart at I T.A.K.E. Unconference ...
Cyrille Martraire: Living Documentation Jumpstart at I T.A.K.E. Unconference ...
 
Cyrille Martraire: Monoids, Monoids Everywhere! at I T.A.K.E. Unconference 2015
Cyrille Martraire: Monoids, Monoids Everywhere! at I T.A.K.E. Unconference 2015Cyrille Martraire: Monoids, Monoids Everywhere! at I T.A.K.E. Unconference 2015
Cyrille Martraire: Monoids, Monoids Everywhere! at I T.A.K.E. Unconference 2015
 
Andrei Petcu: Rocket vs Docker: Battle for the Linux Container at I T.A.K.E. ...
Andrei Petcu: Rocket vs Docker: Battle for the Linux Container at I T.A.K.E. ...Andrei Petcu: Rocket vs Docker: Battle for the Linux Container at I T.A.K.E. ...
Andrei Petcu: Rocket vs Docker: Battle for the Linux Container at I T.A.K.E. ...
 
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
Simon Brown: Software Architecture as Code at I T.A.K.E. Unconference 2015
 
Patroklos Papapetrou: How to Boost Development Team’s Speed at I T.A.K.E. Unc...
Patroklos Papapetrou: How to Boost Development Team’s Speed at I T.A.K.E. Unc...Patroklos Papapetrou: How to Boost Development Team’s Speed at I T.A.K.E. Unc...
Patroklos Papapetrou: How to Boost Development Team’s Speed at I T.A.K.E. Unc...
 
Patroklos Papapetrou: Holding Down Your Technical Debt With SonarQube at I T....
Patroklos Papapetrou: Holding Down Your Technical Debt With SonarQube at I T....Patroklos Papapetrou: Holding Down Your Technical Debt With SonarQube at I T....
Patroklos Papapetrou: Holding Down Your Technical Debt With SonarQube at I T....
 
Robert Mircea & Virgil Chereches: Our Journey To Continuous Delivery at I T.A...
Robert Mircea & Virgil Chereches: Our Journey To Continuous Delivery at I T.A...Robert Mircea & Virgil Chereches: Our Journey To Continuous Delivery at I T.A...
Robert Mircea & Virgil Chereches: Our Journey To Continuous Delivery at I T.A...
 
James Lewis: Microservices - Systems That Are #neverdone at I T.A.K.E. Unconf...
James Lewis: Microservices - Systems That Are #neverdone at I T.A.K.E. Unconf...James Lewis: Microservices - Systems That Are #neverdone at I T.A.K.E. Unconf...
James Lewis: Microservices - Systems That Are #neverdone at I T.A.K.E. Unconf...
 
Flavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. Unconference
Flavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. UnconferenceFlavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. Unconference
Flavius Ștef: Big Rewrites Without Big Risks at I T.A.K.E. Unconference
 
Adi Bolboacă: Architecture For Disaster Resistant Systems at I T.A.K.E. Unco...
Adi Bolboacă: Architecture For Disaster Resistant Systems at I T.A.K.E. Unco...Adi Bolboacă: Architecture For Disaster Resistant Systems at I T.A.K.E. Unco...
Adi Bolboacă: Architecture For Disaster Resistant Systems at I T.A.K.E. Unco...
 
Alex Bolboacă: Why You Should Start Using Docker at I T.A.K.E. Unconference ...
Alex Bolboacă: Why You Should Start Using Docker at I T.A.K.E. Unconference ...Alex Bolboacă: Why You Should Start Using Docker at I T.A.K.E. Unconference ...
Alex Bolboacă: Why You Should Start Using Docker at I T.A.K.E. Unconference ...
 
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
 
Svetlana Mukhina: Metrics That Bring Value at I T.A.K.E. Unconference 2015
Svetlana Mukhina: Metrics That Bring Value at I T.A.K.E. Unconference 2015Svetlana Mukhina: Metrics That Bring Value at I T.A.K.E. Unconference 2015
Svetlana Mukhina: Metrics That Bring Value at I T.A.K.E. Unconference 2015
 
Aki Salmi: Object Oriented Views at I T.A.K.E. Unconference 2015
Aki Salmi: Object Oriented Views at I T.A.K.E. Unconference 2015Aki Salmi: Object Oriented Views at I T.A.K.E. Unconference 2015
Aki Salmi: Object Oriented Views at I T.A.K.E. Unconference 2015
 
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Sandro Mancuso – Testing and refactoring legacy code @ I T.A.K.E. Unconference 2013, Bucharest