SlideShare a Scribd company logo
1 of 48
TDD: seriously, try it ! 😃
2Confidential
First thingfirst
3Confidential
Whythis session?
• Understand the basics around TDD
• Be able building a software starting with tests
• Understand the benefits of building code
covered by tests
VS
building the tests after we write our code
(before VS after)
• Code a bit (and probably) learn something
new from your colleagues
• … 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!
6Confidential
Warning
Basedon my*personal*experience
7Confidential
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
8Confidential
• Where it cames from?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• 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
16Confidential
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
Confidential 17
Theprocess
Confidential 18
 Focus on building tests first that will help us demonstrate the
behaviour we want.
 Wewill start writing tests and we can’t writeverymuchapart
from a unittest. Tests are first class citizens
 No overengineering, simple code, simple solution: makethe 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
• Questions?
• Demo
• Pair programming
• Kata
• 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
• Ourtest 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
• Practicewithsomebody else (pair-programming)
• Practice...
• ... and continues to practice
• ... and continues
• ... until you finally internalizeit 🖖♀️
• Checkonline content
But, howto start?
Confidential 25
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
26Confidential
Questions?
Confidential 27
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
Confidential 28
Warning –Live coding!
Confidential 29
Demo/ Kata 1:FizzBuzz
• https://kata-log.rocks/fizz-buzz-kata • Write a program that prints one linefor each numberfrom 1 to
100
• For multiples of 3 print Fizzinstead of the number
• For the multiples of 5 print Buzzinstead of thenumber
• For numberswhich are multiples of both 3 and 5
print FizzBuzzinstead of thenumber
Confidential 30
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
Confidential 31
• 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 32
• Theprocess is:
1. One person (A) writes a newtest and verifies that it fails 🔴
2. Theother developer (B) implements the code needed to pass the test ✅
3. (optional) -Theother developer (B) decides to refactor part of the code
4. Theother developer (B) writes thenext test and verifies that it fails 🔴
5. Thefirst developer (A) implements thecode needed to pass thetest ✅
Ping-pongpairprogramming
Confidential 33
Thinkaboutcraftmanship
• Be patience, don’t rush.
• Tryto learn as muchas youcan from your colleague
• No pair pressure -> negotiation for the win!
• Write code youwill be proud of 😃👍
Confidential 34
Be kind and respectful
Confidential 35
Are youready?
Confidential 36
Let’s play!
Confidential 37
Kata:Leap year
• As a user, I want to know if a yearis a leap yearor not. • All yearsdivisible by400are leap years (so, for example, 2000
was indeed a leap year),
• All yearsdivisible by100but not by 400 are NOTleap years (so,
for example, 1700,1800,and 1900were not leap years, NORwill
2100bea leap year),
• All yearsdivisible by 4but not by100are leap years (e.g., 2008,
2012,2016),
• All yearsnot divisible by4 are NOT leap years (e.g. 2017,2018,
2019).
Confidential 38
Kata:String calculator
• Createa simple String calculator with a method signature:
int Add(string numbers)
• Themethod can takeup to two numbers, separated by commas,
and will returntheir sum.
Examples:
• “” or “1” or “1,2” as inputs.
• For an empty string it will return0.
Confidential 39
Kata:String calculator
• Iteration 1
Allow theAdd method to handle an unknownamountof
numbers.
Confidential 40
Kata:String calculator
• Iteration 2
Allow theAdd method to handle newlinesbetween numbers
(instead of commas).
Examples:
• Thefollowing input is ok: “1n2,3”(will equal 6)
• Thefollowing input is NOTok: “1,n” (not need to proveit -just
clarifying)
Confidential 41
Kata:String calculator
• Iteration 3
Support different delimiters:
• To change adelimiter, the beginning ofthe string will contain a
separate line that looks like this: “//[delimiter]n[numbers…]” for
example “//;n1;2” should return three where the default delimiter
is‘;’.
• The firstline is optional. All existing scenarios should still be
supported.
Confidential 42
Kata:String calculator
• Iteration 4
Calling Add with a negative numberwill throw an
exception “negatives not allowed” -and the negative that was
passed.
• If there are multiple negatives, show all of them in the exception
message.
Confidential 43
Kata:String calculator
• Iteration 5
Numbersbigger than 1000should be ignored.
• Ifyou want more,you can playmore!See: https://kata-
log.rocks/string-calculator-kata
Example:
• 2+ 1001= 2
Confidential 44
• Whereit camesfrom?
• Advantages & disadvantages
• Process &rules
• Good habits
• Questions?
• Demo
• Pair programming
• Kata
• Final Recap
Agenda
Confidential 45
• 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 46
• TDD helpsyouto develop yourcode in a simple and effective way
👌
• 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
47Confidential
nacho@cougil.com
https://nacho.cougil.com
@icougil
Questions?
I need yourfeedback, please:
https://bit.ly/tdd-seriously-try-it-feedback
48Confidential

More Related Content

What's hot

TDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDTDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDDavid Rodenas
 
Tdd practices
Tdd practicesTdd practices
Tdd practicesaxykim00
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012Pietro Di Bello
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentLim Chanmann
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018Paulo Clavijo
 
Being a professional software tester
Being a professional software testerBeing a professional software tester
Being a professional software testerAnton Keks
 
Scrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerScrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerAnton Keks
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeExcella
 
LCA13: Upstreaming 101
LCA13: Upstreaming 101LCA13: Upstreaming 101
LCA13: Upstreaming 101Linaro
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012Alan Christensen
 
Test driven development vs Behavior driven development
Test driven development vs Behavior driven developmentTest driven development vs Behavior driven development
Test driven development vs Behavior driven developmentGallop Solutions
 
Lessons learned with Bdd: a tutorial
Lessons learned with Bdd: a tutorialLessons learned with Bdd: a tutorial
Lessons learned with Bdd: a tutorialAlan Richardson
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 

What's hot (20)

TDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDTDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDD
 
Tdd practices
Tdd practicesTdd practices
Tdd practices
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
Test drive on driven development process
Test drive on driven development processTest drive on driven development process
Test drive on driven development process
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Tdd com Java
Tdd com JavaTdd com Java
Tdd com Java
 
TDD = bra design?
TDD = bra design?TDD = bra design?
TDD = bra design?
 
Tdd
TddTdd
Tdd
 
Tdd
TddTdd
Tdd
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018
 
Being a professional software tester
Being a professional software testerBeing a professional software tester
Being a professional software tester
 
Scrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineerScrum is not enough - being a successful agile engineer
Scrum is not enough - being a successful agile engineer
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
LCA13: Upstreaming 101
LCA13: Upstreaming 101LCA13: Upstreaming 101
LCA13: Upstreaming 101
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012
 
Test driven development vs Behavior driven development
Test driven development vs Behavior driven developmentTest driven development vs Behavior driven development
Test driven development vs Behavior driven development
 
Test driven development(tdd)
Test driven development(tdd)Test driven development(tdd)
Test driven development(tdd)
 
Lessons learned with Bdd: a tutorial
Lessons learned with Bdd: a tutorialLessons learned with Bdd: a tutorial
Lessons learned with Bdd: a tutorial
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 

Similar to TDD: seriously, try it! 

TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)Nacho Cougil
 
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekNacho Cougil
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)ssusercaf6c1
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)Nacho Cougil
 
Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)wolframkriesing
 
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
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Danny Preussler
 
An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)Rodrigo Lopes
 
Take Pride in Your Code - Test-Driven Development
Take Pride in Your Code - Test-Driven DevelopmentTake Pride in Your Code - Test-Driven Development
Take Pride in Your Code - Test-Driven DevelopmentBADR
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....Mike Harris
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1Blue Elephant Consulting
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is ImportaintSana Nasar
 
Kata Your Way to SW Craftsmanship
Kata Your Way to SW CraftsmanshipKata Your Way to SW Craftsmanship
Kata Your Way to SW CraftsmanshipCamille Bell
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testingdn
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testingmalcolmt
 
Bigger Unit Test Are Better
Bigger Unit Test Are BetterBigger Unit Test Are Better
Bigger Unit Test Are BetterPeter Schuler
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeNacho Cougil
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 

Similar to TDD: seriously, try it!  (20)

TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
 
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
 
Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 
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
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)
 
Take Pride in Your Code - Test-Driven Development
Take Pride in Your Code - Test-Driven DevelopmentTake Pride in Your Code - Test-Driven Development
Take Pride in Your Code - Test-Driven Development
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
Kata Your Way to SW Craftsmanship
Kata Your Way to SW CraftsmanshipKata Your Way to SW Craftsmanship
Kata Your Way to SW Craftsmanship
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testing
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testing
 
Bigger Unit Test Are Better
Bigger Unit Test Are BetterBigger Unit Test Are Better
Bigger Unit Test Are Better
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - Opensouthcode
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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...
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

TDD: seriously, try it! 

  • 3. 3Confidential Whythis session? • Understand the basics around TDD • Be able building a software starting with tests • Understand the benefits of building code covered by tests VS building the tests after we write our code (before VS after) • Code a bit (and probably) learn something new from your colleagues • … 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. 7Confidential • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 8. 8Confidential • Where it cames from? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • 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. 16Confidential • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 18. Confidential 18  Focus on building tests first that will help us demonstrate the behaviour we want.  Wewill start writing tests and we can’t writeverymuchapart from a unittest. Tests are first class citizens  No overengineering, simple code, simple solution: makethe 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 • Questions? • Demo • Pair programming • Kata • 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 • Ourtest 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 • Practicewithsomebody else (pair-programming) • Practice... • ... and continues to practice • ... and continues • ... until you finally internalizeit 🖖♀️ • Checkonline content But, howto start?
  • 25. Confidential 25 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 27. Confidential 27 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 29. Confidential 29 Demo/ Kata 1:FizzBuzz • https://kata-log.rocks/fizz-buzz-kata • Write a program that prints one linefor each numberfrom 1 to 100 • For multiples of 3 print Fizzinstead of the number • For the multiples of 5 print Buzzinstead of thenumber • For numberswhich are multiples of both 3 and 5 print FizzBuzzinstead of thenumber
  • 30. Confidential 30 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 31. Confidential 31 • 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
  • 32. Confidential 32 • Theprocess is: 1. One person (A) writes a newtest and verifies that it fails 🔴 2. Theother developer (B) implements the code needed to pass the test ✅ 3. (optional) -Theother developer (B) decides to refactor part of the code 4. Theother developer (B) writes thenext test and verifies that it fails 🔴 5. Thefirst developer (A) implements thecode needed to pass thetest ✅ Ping-pongpairprogramming
  • 33. Confidential 33 Thinkaboutcraftmanship • Be patience, don’t rush. • Tryto learn as muchas youcan from your colleague • No pair pressure -> negotiation for the win! • Write code youwill be proud of 😃👍
  • 34. Confidential 34 Be kind and respectful
  • 37. Confidential 37 Kata:Leap year • As a user, I want to know if a yearis a leap yearor not. • All yearsdivisible by400are leap years (so, for example, 2000 was indeed a leap year), • All yearsdivisible by100but not by 400 are NOTleap years (so, for example, 1700,1800,and 1900were not leap years, NORwill 2100bea leap year), • All yearsdivisible by 4but not by100are leap years (e.g., 2008, 2012,2016), • All yearsnot divisible by4 are NOT leap years (e.g. 2017,2018, 2019).
  • 38. Confidential 38 Kata:String calculator • Createa simple String calculator with a method signature: int Add(string numbers) • Themethod can takeup to two numbers, separated by commas, and will returntheir sum. Examples: • “” or “1” or “1,2” as inputs. • For an empty string it will return0.
  • 39. Confidential 39 Kata:String calculator • Iteration 1 Allow theAdd method to handle an unknownamountof numbers.
  • 40. Confidential 40 Kata:String calculator • Iteration 2 Allow theAdd method to handle newlinesbetween numbers (instead of commas). Examples: • Thefollowing input is ok: “1n2,3”(will equal 6) • Thefollowing input is NOTok: “1,n” (not need to proveit -just clarifying)
  • 41. Confidential 41 Kata:String calculator • Iteration 3 Support different delimiters: • To change adelimiter, the beginning ofthe string will contain a separate line that looks like this: “//[delimiter]n[numbers…]” for example “//;n1;2” should return three where the default delimiter is‘;’. • The firstline is optional. All existing scenarios should still be supported.
  • 42. Confidential 42 Kata:String calculator • Iteration 4 Calling Add with a negative numberwill throw an exception “negatives not allowed” -and the negative that was passed. • If there are multiple negatives, show all of them in the exception message.
  • 43. Confidential 43 Kata:String calculator • Iteration 5 Numbersbigger than 1000should be ignored. • Ifyou want more,you can playmore!See: https://kata- log.rocks/string-calculator-kata Example: • 2+ 1001= 2
  • 44. Confidential 44 • Whereit camesfrom? • Advantages & disadvantages • Process &rules • Good habits • Questions? • Demo • Pair programming • Kata • Final Recap Agenda
  • 45. Confidential 45 • 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
  • 46. Confidential 46 • TDD helpsyouto develop yourcode in a simple and effective way 👌 • 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

Editor's Notes

  1. Around 2hs: Theorical content - 35mins 1st practice (demo) - 15mins 2nd practice (by attendees) – 50’ – 40-50mins 3rd practice (by attendees) – 1:30-40 Final recap – 1:40 - 15-20mins
  2. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  3. Kent Beck’s book… Developed XP during his work at Chrysler
  4. VS create tests after…
  5. You have to kind of "break" your rules and think outside your comfort zone
  6. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  7. 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
  8. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  9. Nacho -
  10. Nacho - (copy the image in the Slack Channel ?)
  11. Nacho -
  12. Nacho -
  13. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  14. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  15. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  16. This back-and-forth between test and code, driver and navigator, can offer better/richer feedback when building a system.
  17. Bootstrap templates https://github.com/swkBerlin/kata-bootstraps
  18. Around 2hs: Theorical content - 35-40mins (demo) - 15mins 1st practice (by attendees) – 60’ – 40-50mins Final recap – 1:50 - 5-10mins
  19. XP explained – 1st time TDD appeared – nice intro to XP practices 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