SlideShare ist ein Scribd-Unternehmen logo
1 von 35
TDD: seriously,
try it ! 😃
May ‘23
First thing first
• Review the basics around TDD
• Understand the benefits of
building code designed by tests
VS
building the tests after we write
our code
• (I hope) learn some tips
• See a { live coding } example
• … so do not run away, please!
😉
Why this session?
Nacho Cougil
• Principal Software Engineer at
Dynatrace
• TDD & clean code fan
• Started to write in Java before Y2K
• Founder of the Barcelona Java Users
Group ( BarcelonaJUG ) & co-
founder of the Java and JVM
Barcelona Conference
( JBCNConf  DevBcn )
• Java Champion
• Father, former mountain marathon
runner 😅
Who am I?
Raise your
hand at any
moment!
Ask questions at any time,
please!
Based on my
*personal*
experience
Warning
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
Kent Beck “rediscovered” TDD
when writing first testing
framework SUnit in 1994.
TDD became part of eXtreme
Programming (XP) book in
2000. Developed XP during his
work at Chrysler
The book Test-Driven
Development by Example was
published in 2002
A bit of history
Mockist (London)
• Entry point: acceptance test
• Design from top down
• Main focus on the
interactions between the
components of our solution
• Focus on messages we will
use with our classes. Here is
where mock objects appear
Classical (Chicago)
• Described by Kent Beck
• More emphasis on “discovering” the
internals of our code mainly by
refactoring
• The structure of our classes and
modules emerges as we evolve our
code (ex: removing duplication,
encapsulation, etc)
• Focused on changes in an state or
return values from functions
Two TDD
schools
... follows a simple process ⚙️ that
helps you to design & develop your
software in a straightforward and
incremental ♻️ way (  ⚡ feedback
loop).
… you can find defects earlier ⏱
(when running or designing your
tests)
… you can easily detect regression
errors 🔴
… your software is going to be easier
to refactor because of a safety net ✅
Imagine…
... your software guides you how a
consumer will use your component ⏛
… tests are living documentation (really
🖖 !!)
… the software you write it is likely to
have less bugs 🐛
… your development costs 💰 will be
lower
References:
- Test-driven development as a defect-reduction practice
(IEEE)
Imagine…
It is not so easy to start with 😅
(not many good places to help, majority
of people are not using it daily)
Has a high learning curve 😟
(depends directly on the complexity of
your code + your design and
engineering capabilities)
Can be a large investment 💸 in a
team (depending on the experience of
the members + requires time ⏱ & effort
🙇♀️🙇♂️)
Yes, TDD has some disadvantages
It is really easy to forget 😓 about it
It provokes resistance ☹️ (in some
people ⚔️)
Can be corrupted and lead to the
syndrome of reaching the highest
possible level of coverage 🙈
It is extremely difficult 😤 to master at it
Yes, TDD has some disadvantages
You learned how to write code time
ago,…
…and now you’d may learn a different
way of writing software. Like “learning
to ride a very different bike”,... but being
So, … how it is?
To be used in your design &
coding process , for
building better modularized
and tested software
And, what does it
seek?
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
The process
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
Start little by little: katas, POCs,
personal projects, ...
Practice...
• ... and keep practicing
• ... and keep on
• ... until you finally internalise it ⏱♀️😉
Practice with somebody else
( pair-programming )
Keep learning: online content, books,
...
Learn and practice
An Extreme Programming (XP)
Practice in which 2 developers participate
in one development effort at one
workstation.
One, the driver, writes code while the
other, the navigator or observer,
reviews the code as it is typed in. The 2
engineers switch roles frequently.
While reviewing, the observer also
considers the "strategic" direction of the
work, coming up with ideas for
Pair programming
Martin Fowler (concepts)
• https://www.martinfowler.com/bliki/TestDouble.html
• https://martinfowler.com/articles/mocksArentStubs.h
tml
• https://martinfowler.com/articles/practical-test-
pyramid.html
Dave Farley (CI, TDD, etc)
• https://www.youtube.com/ContinuousDelivery/
James Shore (TDD series)
• https://www.youtube.com/jdlshore/
Jason Gorman (Java Code Craft)
• https://www.youtube.com/parlezuml/
Recommended
content
Before you write production code,
check 👀 that your test is failing 🔴
Each test has only 1 reason to fail
Write the assertion first
Technical good habits
Tests naming convention
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
Our tests methods will only describe
behavior. Therefore, we will have a
better understanding on what this class
does
Our tests will be more clear
If some tests fails, we can have a look
and see easily which case is failing
We don’t need to get into details on
any test to understand what are they
pursuing
The result will be focused on the
business
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
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
Warning – Live coding!
Requirements:
• Build a service that returns a list of films
that are associated with a particular genre
• By default, the result must be ordered
according to the average rating given to the
films by the users
• A film should contain at least an id, title a
year when it was published, one or more
tags and one or more genres
Example:
recommendationService.filmsByGenre(”science-
fiction”)
https://github.com/icougil/FilmRecommendationService
We have just started working in a startup
that sells and rents out films over the
Internet
Our product managers have told us that
they want to add new functionalities by
building a service that allows them to
recommend films to the users of the
current platform.
Kata: Film Recommendation Service
• Where it cames from?
• Advantages &
disadvantages
• Process
• Good habits
• Example
• Final Recap
Agenda
• TDD helps you to design & develop
your code in a simple and effective way
(iterative, faster & better modular design)
👌
• It is difficult to adapt to its mechanics
and sometimes is difficult 😅 to maintain
its practice...
• It worth a try 😉 (your software will have
less bugs 🐛 & it will be easier to
maintain 💰)
• There are some tips 💡
( could make your life easier )
• Try to pair, it will help 😃 you ( a lot )
• Practice, practice & practice ⏱ again
Final Recap
Questions?
nacho@cougil.com
https://nacho.cougil.com
@icougil
TDD - Seriously, try it! - Bucarest Tech Week

Weitere ähnliche Inhalte

Ähnlich wie TDD - Seriously, try it! - Bucarest Tech Week

TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)Peter Kofler
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScriptRob Scaduto
 
Test Driven Development using QUnit
Test Driven Development using QUnitTest Driven Development using QUnit
Test Driven Development using QUnitsatejsahu
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is ImportaintSana Nasar
 
What a DevOps specialist has to know about static code analysis
What a DevOps specialist has to know about static code analysisWhat a DevOps specialist has to know about static code analysis
What a DevOps specialist has to know about static code analysisAndrey Karpov
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
Sharpest tool in the box: Choosing the right authoring tool for your learning...
Sharpest tool in the box: Choosing the right authoring tool for your learning...Sharpest tool in the box: Choosing the right authoring tool for your learning...
Sharpest tool in the box: Choosing the right authoring tool for your learning...Brightwave Group
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Hiroyuki Ito
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Jason Tice
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia eventXebia India
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introductionFreekDB
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile DeveloperBSGAfrica
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Ortus Solutions, Corp
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated TestingLars Thorup
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testingBestBrains
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Maven Logix
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Uma Ghotikar
 

Ähnlich wie TDD - Seriously, try it! - Bucarest Tech Week (20)

TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
 
Test Driven Development using QUnit
Test Driven Development using QUnitTest Driven Development using QUnit
Test Driven Development using QUnit
 
What is xp
What is xpWhat is xp
What is xp
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
Agile
AgileAgile
Agile
 
What a DevOps specialist has to know about static code analysis
What a DevOps specialist has to know about static code analysisWhat a DevOps specialist has to know about static code analysis
What a DevOps specialist has to know about static code analysis
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Sharpest tool in the box: Choosing the right authoring tool for your learning...
Sharpest tool in the box: Choosing the right authoring tool for your learning...Sharpest tool in the box: Choosing the right authoring tool for your learning...
Sharpest tool in the box: Choosing the right authoring tool for your learning...
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
 
Code reviews: a short introduction
Code reviews: a short introductionCode reviews: a short introduction
Code reviews: a short introduction
 
Enter the mind of an Agile Developer
Enter the mind of an Agile DeveloperEnter the mind of an Agile Developer
Enter the mind of an Agile Developer
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 

Mehr von Nacho Cougil

Refactor your code: when, why and how (revisited)
Refactor your code: when, why and how (revisited)Refactor your code: when, why and how (revisited)
Refactor your code: when, why and how (revisited)Nacho Cougil
 
TDD: seriously, try it! 
TDD: seriously, try it! TDD: seriously, try it! 
TDD: seriously, try it! Nacho Cougil
 
Refactor your code: when, why and how?
Refactor your code: when, why and how?Refactor your code: when, why and how?
Refactor your code: when, why and how?Nacho Cougil
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDDNacho Cougil
 
BarcelonaJUG at GDG summit
BarcelonaJUG at GDG summitBarcelonaJUG at GDG summit
BarcelonaJUG at GDG summitNacho Cougil
 
Be clean, my friend (Clean code review by BarcelonaJUG)
Be clean, my friend (Clean code review by BarcelonaJUG)Be clean, my friend (Clean code review by BarcelonaJUG)
Be clean, my friend (Clean code review by BarcelonaJUG)Nacho Cougil
 
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...Nacho Cougil
 

Mehr von Nacho Cougil (8)

Refactor your code: when, why and how (revisited)
Refactor your code: when, why and how (revisited)Refactor your code: when, why and how (revisited)
Refactor your code: when, why and how (revisited)
 
TDD: seriously, try it! 
TDD: seriously, try it! TDD: seriously, try it! 
TDD: seriously, try it! 
 
Refactor your code: when, why and how?
Refactor your code: when, why and how?Refactor your code: when, why and how?
Refactor your code: when, why and how?
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
BarcelonaJUG at GDG summit
BarcelonaJUG at GDG summitBarcelonaJUG at GDG summit
BarcelonaJUG at GDG summit
 
Be clean, my friend (Clean code review by BarcelonaJUG)
Be clean, my friend (Clean code review by BarcelonaJUG)Be clean, my friend (Clean code review by BarcelonaJUG)
Be clean, my friend (Clean code review by BarcelonaJUG)
 
Gencat Notifier
Gencat NotifierGencat Notifier
Gencat Notifier
 
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...
Seghismed - Disseny i desenvolupament d'un esquema criptogràfic per gestionar...
 

Kürzlich hochgeladen

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
 
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
 
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
 
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.pdfUK Journal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
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
 
[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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
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...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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...Enterprise Knowledge
 
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
 
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
 
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.pdfsudhanshuwaghmare1
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro 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
 

Kürzlich hochgeladen (20)

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
 
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
 
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)
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.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
 
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
 
[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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 
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...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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...
 
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...
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

TDD - Seriously, try it! - Bucarest Tech Week

  • 1. TDD: seriously, try it ! 😃 May ‘23
  • 3. • Review the basics around TDD • Understand the benefits of building code designed by tests VS building the tests after we write our code • (I hope) learn some tips • See a { live coding } example • … so do not run away, please! 😉 Why this session?
  • 4. Nacho Cougil • Principal Software Engineer at Dynatrace • TDD & clean code fan • Started to write in Java before Y2K • Founder of the Barcelona Java Users Group ( BarcelonaJUG ) & co- founder of the Java and JVM Barcelona Conference ( JBCNConf  DevBcn ) • Java Champion • Father, former mountain marathon runner 😅 Who am I?
  • 5. Raise your hand at any moment! Ask questions at any time, please!
  • 7. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 8. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 9. Kent Beck “rediscovered” TDD when writing first testing framework SUnit in 1994. TDD became part of eXtreme Programming (XP) book in 2000. Developed XP during his work at Chrysler The book Test-Driven Development by Example was published in 2002 A bit of history
  • 10. Mockist (London) • Entry point: acceptance test • Design from top down • Main focus on the interactions between the components of our solution • Focus on messages we will use with our classes. Here is where mock objects appear Classical (Chicago) • Described by Kent Beck • More emphasis on “discovering” the internals of our code mainly by refactoring • The structure of our classes and modules emerges as we evolve our code (ex: removing duplication, encapsulation, etc) • Focused on changes in an state or return values from functions Two TDD schools
  • 11.
  • 12. ... follows a simple process ⚙️ that helps you to design & develop your software in a straightforward and incremental ♻️ way (  ⚡ feedback loop). … you can find defects earlier ⏱ (when running or designing your tests) … you can easily detect regression errors 🔴 … your software is going to be easier to refactor because of a safety net ✅ Imagine…
  • 13. ... your software guides you how a consumer will use your component ⏛ … tests are living documentation (really 🖖 !!) … the software you write it is likely to have less bugs 🐛 … your development costs 💰 will be lower References: - Test-driven development as a defect-reduction practice (IEEE) Imagine…
  • 14. It is not so easy to start with 😅 (not many good places to help, majority of people are not using it daily) Has a high learning curve 😟 (depends directly on the complexity of your code + your design and engineering capabilities) Can be a large investment 💸 in a team (depending on the experience of the members + requires time ⏱ & effort 🙇♀️🙇♂️) Yes, TDD has some disadvantages
  • 15. It is really easy to forget 😓 about it It provokes resistance ☹️ (in some people ⚔️) Can be corrupted and lead to the syndrome of reaching the highest possible level of coverage 🙈 It is extremely difficult 😤 to master at it Yes, TDD has some disadvantages
  • 16.
  • 17. You learned how to write code time ago,… …and now you’d may learn a different way of writing software. Like “learning to ride a very different bike”,... but being So, … how it is?
  • 18. To be used in your design & coding process , for building better modularized and tested software And, what does it seek?
  • 19. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 21. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 22. Start little by little: katas, POCs, personal projects, ... Practice... • ... and keep practicing • ... and keep on • ... until you finally internalise it ⏱♀️😉 Practice with somebody else ( pair-programming ) Keep learning: online content, books, ... Learn and practice
  • 23. An Extreme Programming (XP) Practice in which 2 developers participate in one development effort at one workstation. One, the driver, writes code while the other, the navigator or observer, reviews the code as it is typed in. The 2 engineers switch roles frequently. While reviewing, the observer also considers the "strategic" direction of the work, coming up with ideas for Pair programming
  • 24. Martin Fowler (concepts) • https://www.martinfowler.com/bliki/TestDouble.html • https://martinfowler.com/articles/mocksArentStubs.h tml • https://martinfowler.com/articles/practical-test- pyramid.html Dave Farley (CI, TDD, etc) • https://www.youtube.com/ContinuousDelivery/ James Shore (TDD series) • https://www.youtube.com/jdlshore/ Jason Gorman (Java Code Craft) • https://www.youtube.com/parlezuml/ Recommended content
  • 25. Before you write production code, check 👀 that your test is failing 🔴 Each test has only 1 reason to fail Write the assertion first Technical good habits
  • 26. Tests naming convention 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
  • 27. Our tests methods will only describe behavior. Therefore, we will have a better understanding on what this class does Our tests will be more clear If some tests fails, we can have a look and see easily which case is failing We don’t need to get into details on any test to understand what are they pursuing The result will be focused on the business
  • 28. 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
  • 29. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 30. Warning – Live coding!
  • 31. Requirements: • Build a service that returns a list of films that are associated with a particular genre • By default, the result must be ordered according to the average rating given to the films by the users • A film should contain at least an id, title a year when it was published, one or more tags and one or more genres Example: recommendationService.filmsByGenre(”science- fiction”) https://github.com/icougil/FilmRecommendationService We have just started working in a startup that sells and rents out films over the Internet Our product managers have told us that they want to add new functionalities by building a service that allows them to recommend films to the users of the current platform. Kata: Film Recommendation Service
  • 32. • Where it cames from? • Advantages & disadvantages • Process • Good habits • Example • Final Recap Agenda
  • 33. • TDD helps you to design & develop your code in a simple and effective way (iterative, faster & better modular design) 👌 • It is difficult to adapt to its mechanics and sometimes is difficult 😅 to maintain its practice... • It worth a try 😉 (your software will have less bugs 🐛 & it will be easier to maintain 💰) • There are some tips 💡 ( could make your life easier ) • Try to pair, it will help 😃 you ( a lot ) • Practice, practice & practice ⏱ again Final Recap

Hinweis der Redaktion

  1. “Take the input tape, manually type in the output tape you expect, then program until the actual output tape matches the expected output.”
  2. VS create tests after…
  3. IEEE = ai triple i   IEEE: case study at IBM 2003 – 40% fewer defects when using TDD The art of fearless: increased effort and/or quality effect (from IEEE) -- good collection of articles and empirical studies on TDD both in private companies and in the academic world
  4. - Forget : especially if you are not in an environment / team that does not encourage its use or you cannot experiment with it comfortably - Having a high level of coverage is an indirect consequence of using/applying TDD
  5. 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
  6. -> min 10-11' This back-and-forth between test and code, driver and navigator, can offer better/richer feedback when building a system. This is intended to free the driver to focus all of their attention on the "tactical" aspects of completing the current task, using the observer as a safety net and guide.
  7. 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
  8. -> min 8 !!!
  9. Nacho -
  10. -> min 12'
  11. Genre = spoke “yonra” -> min 13'