SlideShare a Scribd company logo
1 of 15
Using TDD to understand
Legacy Codes
Copyright 2013
Suradet Jitprapaikulsarn
www.ajarnsuradet.com
Revision 1.0 Using TDD to understand Legacy Codes2
Creative Commons License 3.0
This work is licensed under the Creative
Commons Attribution-NonCommercial-
ShareAlike 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/
or
send a letter to Creative Commons, 171 Second
Street, Suite 300, San Francisco, California,
94105, USA.
Revision 1.0 Using TDD to understand Legacy Codes3
You are free:
to Share — to copy, distribute and transmit the work
to Remix — to adapt the work
Under the following conditions:
Attribution — You must attribute the work in the
manner specified by the author or licensor (but not in
any way that suggests that they endorse you or your
use of the work).
Noncommercial — You may not use this work for
commercial purposes.
Share Alike — If you alter, transform, or build upon
this work, you may distribute the resulting work only
under the same or similar license to this one.
Revision 1.0 Using TDD to understand Legacy Codes4
With the understanding that:
• Waiver — Any of the above conditions can be waived if
you get permission from the copyright holder.
• Public Domain — Where the work or any of its
elements is in the public domain under applicable law,
that status is in no way affected by the license.
• Other Rights — In no way are any of the following rights
affected by the license:
– Your fair dealing or fair use rights, or other applicable copyright
exceptions and limitations;
– The author's moral rights;
– Rights other persons may have either in the work itself or in how
the work is used, such as publicity or privacy rights.
Notice — For any reuse or distribution, you must make
clear to others the license terms of this work. The best
way to do this is with a link to this web page.
Revision 1.0 Using TDD to understand Legacy Codes5
Topics
• Typical TDD Process
• Legacy Code
• Approaches for working with legacy code
• More information
• About Me
Revision 1.0 Using TDD to understand Legacy Codes6
Typical TDD
• “Clean Code that work” – Ron Jeffries
• 2 Simple rules – Kent Beck
– Write new code only if a test has failed
– Get rid of duplication
Revision 1.0 Using TDD to understand Legacy Codes7
TDD Mantra
Red
GreenRefactor
Write a test
that will fail
Make code to
pass tests
Improve the
codes & tests
Source:
K. Beck, Test-Driven
Development by Example,
Addison-Wesley, 2002
Revision 1.0 Using TDD to understand Legacy Codes8
Typical TDD Process
Add a
Test
Run
Tests
Make a
change[Failed]
[Passed]
Run
Tests
[Failed]
[Passed but not done]
[Passed
& Done]
Revision 1.0 Using TDD to understand Legacy Codes9
Suitable Scenarios
• Perfect for new code
• Assume that called elements are
trustworthy and testable
• Green field
 Well-understood, testable code
Characteristics of Legacy
Code
Revision 1.0 Using TDD to understand Legacy Codes11
Legacy Code
• Existing code
• A lot of doubts about elements
• Some elements have some problems
• Brown field
Revision 1.0 Using TDD to understand Legacy Codes12
Approaches for working with legacy
code
• Wrapped code
• Sprout method
• ATDD / BDD
• Etc
Revision 1.0 Using TDD to understand Legacy Codes13
More information
1. K. Beck, Test-Driven Development by
Example. Addison-Wesley, 2003.
2. M. Features, Working Effectively with
Legacy Code. Prentice Hall, 2004.
Revision 1.0 Using TDD to understand Legacy Codes14
About Presenter
• Suradet Jitprapaikulsarn, Ph.D.
• Lecturer
• Department of Electrical and Computer
Engineering, Naresuan University,
Phitsanulok
• Email: suradet.j@gmail.com
• Facebook: Suradet Jitprapaikulsarn
Revision 1.0 Using TDD to understand Legacy Codes15
About Me (Cont.)
• Apply PSP since 1997
• Apply TDD since 1999
• 1st
Thai ScrumMaster, since 2009
• Was the only authorized PSP instructor in
Southeast Asia
• 1st
Certified PSP developer
• 5 times CMMI appraisal team member
• Only Asian instructor invited for Software
Architecture workshop at SEI, 7 year in a row
(2006 – 2012)

More Related Content

Viewers also liked (12)

Necessary but not sufficient
Necessary but not sufficientNecessary but not sufficient
Necessary but not sufficient
 
Artigo pós hipocapnia
Artigo pós   hipocapniaArtigo pós   hipocapnia
Artigo pós hipocapnia
 
04 basic measurement
04 basic measurement04 basic measurement
04 basic measurement
 
02 intro to psp
02 intro to psp02 intro to psp
02 intro to psp
 
01 process and software development
01 process and software development01 process and software development
01 process and software development
 
03 using psp0
03 using psp003 using psp0
03 using psp0
 
Heliponto
HelipontoHeliponto
Heliponto
 
Agile with legacy product
Agile with legacy productAgile with legacy product
Agile with legacy product
 
DISCURSO DE EMBAJADOR DE ISRAEL EN PANAMÁ EN CELEBRACIÓN DE LOS 64 AÑOS DE IN...
DISCURSO DE EMBAJADOR DE ISRAEL EN PANAMÁ EN CELEBRACIÓN DE LOS 64 AÑOS DE IN...DISCURSO DE EMBAJADOR DE ISRAEL EN PANAMÁ EN CELEBRACIÓN DE LOS 64 AÑOS DE IN...
DISCURSO DE EMBAJADOR DE ISRAEL EN PANAMÁ EN CELEBRACIÓN DE LOS 64 AÑOS DE IN...
 
5. polymerisation practice tepe
5. polymerisation practice tepe5. polymerisation practice tepe
5. polymerisation practice tepe
 
6. polymer characterization 1 new clean short tepe
6. polymer characterization 1 new clean short tepe6. polymer characterization 1 new clean short tepe
6. polymer characterization 1 new clean short tepe
 
Presentasi inovasi
Presentasi inovasiPresentasi inovasi
Presentasi inovasi
 

Similar to Using tdd to understand legacy codes

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsEl Mahdi Benzekri
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentnikhil sreeni
 
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit TestsClean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Testsradin reth
 
Bdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriBdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriCommit University
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentMeilan Ou
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...DevDay.org
 
Code sense
Code senseCode sense
Code sensenasirj
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptxAmalEldhose2
 
Net essentials6e ch13
Net essentials6e ch13Net essentials6e ch13
Net essentials6e ch13APSU
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieQA or the Highway
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Arnaud Bouchez
 
Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Malinda Kapuruge
 
Refactoring, Therapeutic Attitude to Programming.
Refactoring, Therapeutic Attitude to Programming.Refactoring, Therapeutic Attitude to Programming.
Refactoring, Therapeutic Attitude to Programming.Amin Shahnazari
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference CardSeapine Software
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsBill Buchan
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven DevelopmentMichael Denomy
 

Similar to Using tdd to understand legacy codes (20)

Thesis proposal checklist
Thesis proposal checklistThesis proposal checklist
Thesis proposal checklist
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices Antipatterns
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years afterIan Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
 
Clean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit TestsClean code: understanding Boundaries and Unit Tests
Clean code: understanding Boundaries and Unit Tests
 
Bdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propriBdd - L'arte di non farsi i fatti propri
Bdd - L'arte di non farsi i fatti propri
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Code quality
Code quality Code quality
Code quality
 
Code sense
Code senseCode sense
Code sense
 
{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx{10.0} Test Driven Development.pptx
{10.0} Test Driven Development.pptx
 
Net essentials6e ch13
Net essentials6e ch13Net essentials6e ch13
Net essentials6e ch13
 
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzieHey You Got Your TDD in my SQL DB by Jeff McKenzie
Hey You Got Your TDD in my SQL DB by Jeff McKenzie
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
 
Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.
 
Refactoring, Therapeutic Attitude to Programming.
Refactoring, Therapeutic Attitude to Programming.Refactoring, Therapeutic Attitude to Programming.
Refactoring, Therapeutic Attitude to Programming.
 
Test-Driven Development Reference Card
Test-Driven Development Reference CardTest-Driven Development Reference Card
Test-Driven Development Reference Card
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[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.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
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 organizationRadu Cotescu
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Using tdd to understand legacy codes

  • 1. Using TDD to understand Legacy Codes Copyright 2013 Suradet Jitprapaikulsarn www.ajarnsuradet.com
  • 2. Revision 1.0 Using TDD to understand Legacy Codes2 Creative Commons License 3.0 This work is licensed under the Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
  • 3. Revision 1.0 Using TDD to understand Legacy Codes3 You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial — You may not use this work for commercial purposes. Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
  • 4. Revision 1.0 Using TDD to understand Legacy Codes4 With the understanding that: • Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. • Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. • Other Rights — In no way are any of the following rights affected by the license: – Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; – The author's moral rights; – Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
  • 5. Revision 1.0 Using TDD to understand Legacy Codes5 Topics • Typical TDD Process • Legacy Code • Approaches for working with legacy code • More information • About Me
  • 6. Revision 1.0 Using TDD to understand Legacy Codes6 Typical TDD • “Clean Code that work” – Ron Jeffries • 2 Simple rules – Kent Beck – Write new code only if a test has failed – Get rid of duplication
  • 7. Revision 1.0 Using TDD to understand Legacy Codes7 TDD Mantra Red GreenRefactor Write a test that will fail Make code to pass tests Improve the codes & tests Source: K. Beck, Test-Driven Development by Example, Addison-Wesley, 2002
  • 8. Revision 1.0 Using TDD to understand Legacy Codes8 Typical TDD Process Add a Test Run Tests Make a change[Failed] [Passed] Run Tests [Failed] [Passed but not done] [Passed & Done]
  • 9. Revision 1.0 Using TDD to understand Legacy Codes9 Suitable Scenarios • Perfect for new code • Assume that called elements are trustworthy and testable • Green field  Well-understood, testable code
  • 11. Revision 1.0 Using TDD to understand Legacy Codes11 Legacy Code • Existing code • A lot of doubts about elements • Some elements have some problems • Brown field
  • 12. Revision 1.0 Using TDD to understand Legacy Codes12 Approaches for working with legacy code • Wrapped code • Sprout method • ATDD / BDD • Etc
  • 13. Revision 1.0 Using TDD to understand Legacy Codes13 More information 1. K. Beck, Test-Driven Development by Example. Addison-Wesley, 2003. 2. M. Features, Working Effectively with Legacy Code. Prentice Hall, 2004.
  • 14. Revision 1.0 Using TDD to understand Legacy Codes14 About Presenter • Suradet Jitprapaikulsarn, Ph.D. • Lecturer • Department of Electrical and Computer Engineering, Naresuan University, Phitsanulok • Email: suradet.j@gmail.com • Facebook: Suradet Jitprapaikulsarn
  • 15. Revision 1.0 Using TDD to understand Legacy Codes15 About Me (Cont.) • Apply PSP since 1997 • Apply TDD since 1999 • 1st Thai ScrumMaster, since 2009 • Was the only authorized PSP instructor in Southeast Asia • 1st Certified PSP developer • 5 times CMMI appraisal team member • Only Asian instructor invited for Software Architecture workshop at SEI, 7 year in a row (2006 – 2012)

Editor's Notes

  1. Revision History ------------------------ Revision 1.0 (2013-03-23) 1st release for BugDay Bangkok 2013