SlideShare une entreprise Scribd logo
1  sur  33
TDD: seriously, try it ! 😃
2
Confidential
First thingfirst
3
Confidential
Whythis session?
• Review the basics around TDD
• Understand the benefits of building code
designed by tests
VS
building the tests after we write our code
(before VS after)
• See an example
• (I hope) learn some tips
• … so do not run away, please! 😉
Confidential 4
NachoCougil
• Senior Software Engineerat Dynatrace
• TDD &cleancode fan
• Started to write in Javabefore the effect 2000
• Founderof the Barcelona Java Users Group &
co-founderof the Java and JVMBarcelona Conference (JBCNConf)
• Father, formermountain marathonrunner 😅
@icougil
WhoamI?
Confidential 5
• Raise yourhand at anymoment!
Askquestions atanytime,please!
6
Confidential
Warning
Basedon my*personal*experience
7
Confidential
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
8
Confidential
• Where it cames from?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
Confidential 9
• Kent Beck “rediscovered” TDD whenwriting first
testing framework SUnitin1994.
“Taketheinputtape,manuallytypeintheoutput
tapeyouexpect, then programuntiltheactual
outputtapematches the expected output.”
• TDD became part of Extreme Programmingbook
in1999.
Abit of history
Confidential 10
• … youcan find defects earlier ⏱ (when runningor
designing yourtests)
• … youcan easily detect regression errors 🔴
• … youfollow a simple process ⚙️ that helps youto
develop yoursoftware in a straightforward way
• … yoursoftware is going to be easier to refactor
because of ✅ green (safety net)
For a moment,imagine…
Confidential 11
For a moment,imagine…
• ... yoursoftware guides youhow a consumerwill use your
component ⏛
• … tests are living documentation (really 🖖 !!)
• … the software youwrite it is likely to have less bugs 🐛
• … yourdevelopment costs 💰 will be lower
References:
- Test-drivendevelopmentasa defect-reductionpractice(IEEE)
- GuestEditors' Introduction:TDD--TheArt of FearlessProgramming (computer.org)
Confidential 12
Yes,TDDhassomedisadvantages
• It is not so easy to start with 😅
(not manygood places to help, majority of people are not using it
daily)
• Has a highlearningcurve😟
(depends directly on thecomplexity of yourcode + yourdesign
and engineeringcapabilities)
• Can be a largeinvestment 💸 in a team (depending on the
experience of the members + requires time ⏳ &effort 🙇♀️🙇♂️)
Confidential 13
• It is reallyeasy to forget 😓 about it
(especiallyifyou arenot inan environment/ teamthat
does not encourageits use or you cannot experiment
withitcomfortably)
• It provokesresistance☹️ (in somepeople)
• Can be corrupted and lead to the syndromeof reaching
the highest possible levelof coverage🙈
• It is extremelydifficult 😤 to masterat it
Yes,TDDhassomedisadvantages
Confidential 14
So,… how it is?
• Youlearnedhow to write code time ago,…
• …and now you’dmay learn a different way of writing software.
Like“learningto rideaverydifferent bike”,... but being older 😅
Confidential 15
16
Confidential
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
Confidential 17
Theprocess
Confidential 18
 Focus on building tests 1st that will help us demonstrate the
behaviour we want.
 Wewill start writing tests and we can’t writeverymuchapart
from a unittest. Testsare first class citizens
 No overengineering, simple code, simple solution: make the
test pass
• You are not allowed to writeany production code unless it is to
makea failing unit test pass.
• Youare not allowed to write any more of a unit test than is
sufficient to fail.
• Youare not allowed to write any
more production code than is
sufficient topass the one failing
unit test.
Robert C. Martin
(uncleBob)
Therules
Confidential 19
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
Confidential 20
• Before you write production code,
check that your test is failing 🔴!
• Each test has only 1 reason to fail
• Write the assertion first
Goodhabits
Confidential 21
Tests namingconvention
Describe the
expected
behaviour, not
the internals.
Our tests
should describe
behaviour in
plain english
Ending the class name
with Should will “force “
you to start describing
an action for every test
you may create
Confidential 22
• Ourtests methods will only describe behavior.
Thereforewewill havea better understanding on
what this class does
• Ourtests will be moreclear
• If some tests fails, we can havea look and see
easily which case is failing
• Wedon’t need to get into details on anyparticular
test if wedon’t need it
Theresult will befocusedonthe business
Confidential 23
Test creation order
1) Name the class
2) Name the method
3) Define what you want to check
4) Trigger the code
5) Do the setup
Confidential 24
• Startlittleby little...
• Katas
• Proofs of concept
• Personal projects
• Practice...
• ... and keeppracticing
• ... and continues
• ... until you finally internalizeit 🖖♀️😉
• Checkonline content
• Practicewithsomebody else ( pair-programming)-
nextslide👉-
But, howto start?
Confidential 25
• An ExtremeProgramming(XP)Practicein which2 developersparticipate inone
developmenteffort at one workstation.
• One,the driver,writescode whilethe other, the navigator orobserver,reviewsthe
code as it istyped in. The 2engineersswitchrolesfrequently.
• While reviewing,the observeralso considers the "strategic"direction of the work,
coming up with ideas for improvementsand likelyfuture problemsto address.This is
intended to freethe driverto focus all of their attention on the"tactical" aspectsof
completingthe currenttask, using theobserveras a safety netand guide.
Pair programming
Confidential 26
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
Confidential 27
Warning –Live coding!
Confidential 28
Kata:Film RecommendationService
• Wehave just started workingin a startup that sells and
rentsout films over the Internet
• Ourproduct managers have told us that theywant to add
new functionalities by building a service that allows
them to recommendfilms to the users of the current
platform.
• Requirements:
• Build a service that returnsa list of films that are associated with a
particular genre
• By default, the result must be ordered according to the average ratinggiven
to the films by theusers
• A film should contain at least a title, a yearwhenit was published, one or
more tags and one or moregenres
• Example:
• recommendationService.filmsByGenre("science-fiction”)
https://github.com/icougil/FilmRecommendationService
Confidential 29
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Example
• Final Recap
Agenda
Confidential 30
• Martin Fowler (main concepts around testing)
• https://www.martinfowler.com/bliki/TestDouble.html
• https://martinfowler.com/articles/mocksArentStubs.html
• https://martinfowler.com/articles/practical-test-
pyramid.html
• JamesShore(JS practices)
• https://www.youtube.com/user/jdlshore/videos
• Jason Gorman(Java practices)
• https://www.youtube.com/user/parlezuml/videos
Recommendedcontent
Confidential 31
• TDD helpsyouto develop yourcode in a simple and effective way
(better modular design) 👌
• It is difficult to adapt to its mechanicsand sometimes is difficult 😅
to maintainits practice...
• Itworth a try😉 ( yoursoftware will haveless bugs 🐛 & it will be
easier to maintain 💰 )
• Thereare some tips 💡
( could makeyourlife easier )
• Tryto pair, it will help 😃 you (a lot )
• Practice, practice &practice 🖖 again
FinalRecap
32
Confidential
nacho@cougil.com
https://nacho.cougil.com
@icougil
Questions?
I need yourfeedback, please:
https://bit.ly/tdd-seriously-try-it-feedback
33
Confidential

Contenu connexe

Dernier

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 AutomationSafe Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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...Miguel Araújo
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
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...DianaGray10
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
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)wesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Dernier (20)

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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Tdd: seriously, try it! { revisited with live coding }

  • 3. 3 Confidential Whythis session? • Review the basics around TDD • Understand the benefits of building code designed by tests VS building the tests after we write our code (before VS after) • See an example • (I hope) learn some tips • … so do not run away, please! 😉
  • 4. Confidential 4 NachoCougil • Senior Software Engineerat Dynatrace • TDD &cleancode fan • Started to write in Javabefore the effect 2000 • Founderof the Barcelona Java Users Group & co-founderof the Java and JVMBarcelona Conference (JBCNConf) • Father, formermountain marathonrunner 😅 @icougil WhoamI?
  • 5. Confidential 5 • Raise yourhand at anymoment! Askquestions atanytime,please!
  • 7. 7 Confidential • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 8. 8 Confidential • Where it cames from? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 9. Confidential 9 • Kent Beck “rediscovered” TDD whenwriting first testing framework SUnitin1994. “Taketheinputtape,manuallytypeintheoutput tapeyouexpect, then programuntiltheactual outputtapematches the expected output.” • TDD became part of Extreme Programmingbook in1999. Abit of history
  • 10. Confidential 10 • … youcan find defects earlier ⏱ (when runningor designing yourtests) • … youcan easily detect regression errors 🔴 • … youfollow a simple process ⚙️ that helps youto develop yoursoftware in a straightforward way • … yoursoftware is going to be easier to refactor because of ✅ green (safety net) For a moment,imagine…
  • 11. Confidential 11 For a moment,imagine… • ... yoursoftware guides youhow a consumerwill use your component ⏛ • … tests are living documentation (really 🖖 !!) • … the software youwrite it is likely to have less bugs 🐛 • … yourdevelopment costs 💰 will be lower References: - Test-drivendevelopmentasa defect-reductionpractice(IEEE) - GuestEditors' Introduction:TDD--TheArt of FearlessProgramming (computer.org)
  • 12. Confidential 12 Yes,TDDhassomedisadvantages • It is not so easy to start with 😅 (not manygood places to help, majority of people are not using it daily) • Has a highlearningcurve😟 (depends directly on thecomplexity of yourcode + yourdesign and engineeringcapabilities) • Can be a largeinvestment 💸 in a team (depending on the experience of the members + requires time ⏳ &effort 🙇♀️🙇♂️)
  • 13. Confidential 13 • It is reallyeasy to forget 😓 about it (especiallyifyou arenot inan environment/ teamthat does not encourageits use or you cannot experiment withitcomfortably) • It provokesresistance☹️ (in somepeople) • Can be corrupted and lead to the syndromeof reaching the highest possible levelof coverage🙈 • It is extremelydifficult 😤 to masterat it Yes,TDDhassomedisadvantages
  • 14. Confidential 14 So,… how it is? • Youlearnedhow to write code time ago,… • …and now you’dmay learn a different way of writing software. Like“learningto rideaverydifferent bike”,... but being older 😅
  • 16. 16 Confidential • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 18. Confidential 18  Focus on building tests 1st that will help us demonstrate the behaviour we want.  Wewill start writing tests and we can’t writeverymuchapart from a unittest. Testsare first class citizens  No overengineering, simple code, simple solution: make the test pass • You are not allowed to writeany production code unless it is to makea failing unit test pass. • Youare not allowed to write any more of a unit test than is sufficient to fail. • Youare not allowed to write any more production code than is sufficient topass the one failing unit test. Robert C. Martin (uncleBob) Therules
  • 19. Confidential 19 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 20. Confidential 20 • Before you write production code, check that your test is failing 🔴! • Each test has only 1 reason to fail • Write the assertion first Goodhabits
  • 21. Confidential 21 Tests namingconvention Describe the expected behaviour, not the internals. Our tests should describe behaviour in plain english Ending the class name with Should will “force “ you to start describing an action for every test you may create
  • 22. Confidential 22 • Ourtests methods will only describe behavior. Thereforewewill havea better understanding on what this class does • Ourtests will be moreclear • If some tests fails, we can havea look and see easily which case is failing • Wedon’t need to get into details on anyparticular test if wedon’t need it Theresult will befocusedonthe business
  • 23. Confidential 23 Test creation order 1) Name the class 2) Name the method 3) Define what you want to check 4) Trigger the code 5) Do the setup
  • 24. Confidential 24 • Startlittleby little... • Katas • Proofs of concept • Personal projects • Practice... • ... and keeppracticing • ... and continues • ... until you finally internalizeit 🖖♀️😉 • Checkonline content • Practicewithsomebody else ( pair-programming)- nextslide👉- But, howto start?
  • 25. Confidential 25 • An ExtremeProgramming(XP)Practicein which2 developersparticipate inone developmenteffort at one workstation. • One,the driver,writescode whilethe other, the navigator orobserver,reviewsthe code as it istyped in. The 2engineersswitchrolesfrequently. • While reviewing,the observeralso considers the "strategic"direction of the work, coming up with ideas for improvementsand likelyfuture problemsto address.This is intended to freethe driverto focus all of their attention on the"tactical" aspectsof completingthe currenttask, using theobserveras a safety netand guide. Pair programming
  • 26. Confidential 26 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 28. Confidential 28 Kata:Film RecommendationService • Wehave just started workingin a startup that sells and rentsout films over the Internet • Ourproduct managers have told us that theywant to add new functionalities by building a service that allows them to recommendfilms to the users of the current platform. • Requirements: • Build a service that returnsa list of films that are associated with a particular genre • By default, the result must be ordered according to the average ratinggiven to the films by theusers • A film should contain at least a title, a yearwhenit was published, one or more tags and one or moregenres • Example: • recommendationService.filmsByGenre("science-fiction”) https://github.com/icougil/FilmRecommendationService
  • 29. Confidential 29 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Example • Final Recap Agenda
  • 30. Confidential 30 • Martin Fowler (main concepts around testing) • https://www.martinfowler.com/bliki/TestDouble.html • https://martinfowler.com/articles/mocksArentStubs.html • https://martinfowler.com/articles/practical-test- pyramid.html • JamesShore(JS practices) • https://www.youtube.com/user/jdlshore/videos • Jason Gorman(Java practices) • https://www.youtube.com/user/parlezuml/videos Recommendedcontent
  • 31. Confidential 31 • TDD helpsyouto develop yourcode in a simple and effective way (better modular design) 👌 • It is difficult to adapt to its mechanicsand sometimes is difficult 😅 to maintainits practice... • Itworth a try😉 ( yoursoftware will haveless bugs 🐛 & it will be easier to maintain 💰 ) • Thereare some tips 💡 ( could makeyourlife easier ) • Tryto pair, it will help 😃 you (a lot ) • Practice, practice &practice 🖖 again FinalRecap

Notes de l'éditeur

  1. Kent Beck’s book… Developed XP during his work at Chrysler
  2. VS create tests after…
  3. You have to kind of "break" your rules and think outside your comfort zone
  4. Specify what you want to code to do Create just enough code to satisfy the desired behaviour (just make it work!) Clean your code and test / remove duplication / make it better
  5. Nacho -
  6. Nacho - (copy the image in the Slack Channel ?)
  7. Nacho -
  8. Nacho -
  9. This back-and-forth between test and code, driver and navigator, can offer better/richer feedback when building a system.
  10. Genre = spoke “jonra”
  11. GOOST >> TDD learn, understand & apply TDD by example – basic intro, idealised situation… The art of unit testing – easy to read TDD a practical guide – some examples with GUI & real examples