SlideShare a Scribd company logo
Test Driven Development
 and Related Techniques
 For Non-Developers ;-)
        IBM 2012

     Peter Kofler, ‘Code Cop’
         @codecopkofler
       www.code-cop.org
    Copyright Peter Kofler, licensed under CC-BY.
Peter Kofler

•   Ph.D. (Appl. Math.)
•   (Java) Software Developer
•   with IBM since 1 year
•   SDM Costing, IGA, GBS
The opinions expressed here are my
own and do not necessarily represent
 those of current or past employers.
Agenda
1) What does it
  look like?
2) Why is it
  important?
3) What you
  need to do!
4) Summary
1) So what is it all about?



The Prime Factors
  Kata (Demo)
What Exactly Will We Do Now?
●
    write code together
●
    using TDD
●
    see techniques
      and patterns
●
    discuss while
     doing
The Requirements.
• Write a class named “PrimeFactors” that
  has one static method: generate.
  – The generate method takes an integer
    argument and returns a List<Integer>.
  – That list contains the prime factors in
    numerical sequence.



   http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata
First Some Math.
●
 Prime Number: a natural number > 1
that has no divisors other than 1 and itself.
    ●
        e.g. 2, 3, 5, 61, 67, ..., 997, ..., 243112609-1, …
●
 Prime Factors: the prime numbers that
divide an integer exactly without remainder.
    ●
        e.g. 2 = 2,
        4 = 2 * 2,
        24 = 2 * 2 * 2 * 3
        288 = 25 * 32
The Requirements (for Mortals).
• code a file/module/class “PrimeFactors”
• code a function/method/routine
  “generate”
• accept an integer number as parameter
• return the prime factors of that number
Demo
(Code Kata)
Keep the bar green to keep the code clean.
Unit Testing
• test individual units
• isolate each part
• show that the individual parts are correct
• regression testing
• sort of living documentation
• executed within a framework
                       http://en.wikipedia.org/wiki/Unit_testing
Test-Driven Development
• add a test
• run all tests and see if the new one fails
• write some code
• run all tests and see them succeed
• refactor code mercilessly
• „Red Green Refactor“
               http://en.wikipedia.org/wiki/Test_Driven_Development
A minute ago all
their code worked
Refactoring

 Refactoring is a technique
     for restructuring
  an existing body of code,
altering its internal structure
    without changing
    its external behavior.
                          (Martin Fowler)
Refactoring
• small behavior preserving transformations
• sequence of transformations produce a
  significant restructuring
• each transformation is small, less likely to
  go wrong
• system is kept fully working after each
  change
• verified by working tests
TDD and Related Techniques for Non Developers (2012)
Code Coverage

comprehensiveness of tests
Beware!

comprehensiveness  quality!
Small Advice

Never measure
developers by
Code Coverage!
Demo
(Coverage in Eclipse)
Demo
 (Jenkins)
TDD and Related Techniques for Non Developers (2012)
Continuous
Integration
Continuous Integration
•   Maintain a code repository
•   Automate the build
•   Make the build self-testing
•   Everyone commits every day
•   Every commit should be built
•   Keep the build fast
•   Everyone can see the results of the build
                http://en.wikipedia.org/wiki/Continuous_integration
Immediate Feedback
       and
  Early Warning
Demo
 (Jenkins)
2) Why should we use TDD?
• Writing tests takes time
• and we need to    deliver client
 value.
              I don't have time.
              I don't have time.
              I don't have time.
Do you still use that one?
Discussion
• What do you think are the benefits of
  TDD?
  – rapid feedback
  –…
  – ...
Benefits
• speed up
• coverage
  – measurable validation of correctness
• quality
  – proven to save maintenance costs
• creates a detailed specification
Benefits
• improve design
  – drive the design of a program
  – think in exposed API
Problems
• missing management
  buy-in
• high ramp-up time
• still need
  integration
  tests



http://watirmelon.com/2012/01/31/introducing-the-software-testing-ice-cream-cone/
TDD will not fix missing skills!
• badly written tests
  –   brittle
  –   blinking
  –   slow
  –   duplicate code
  –   maintenance burden
  –   wrong abstractions
  –   not really unit tests
Because TDD is hard!
• need to know OO,
  design, abstraction, ...
• new style of thinking
• need self-discipline
• (learning curve)
3) What you need to do
Problem Indicators: CI
• blinking builds
• builds broken for long time
• increasing build
  execution time
• decreasing code
  coverage
Problem Indicators: Tests
•   slow
•   fragile
•   no detailed feedback
•   “Ice-Cream Cone”
Problem Indicators: Developers
• claiming that they can't write tests
• claiming that they can't fix tests
• wanting to delete tests
“Buzzwords” Summary
• Techniques
  –   Unit Testing
  –   Test Driven Development
  –   Refactoring
  –   Code Coverage
  –   Continuous Integration
• Management Buy-In
• Keep an eye on the CI server
Support TDD



Do not compromise
  on techniques!
Thank
 You
Peter Kofler

  @codecopkofler

www.code-cop.org
CC Images
•   Drive: http://www.flickr.com/photos/hjem/367306587/
•   Judge: http://www.flickr.com/photos/eldave/6169431454/
•   List: http://www.flickr.com/photos/kylesteeddesign/3724074594/
•   Question mark: http://www.flickr.com/photos/oberazzi/318947873/
•   Fence: http://www.flickr.com/photos/30830597@N08/3630649274/
•   Coverage: http://www.flickr.com/photos/paulk/3166328163/
•   Works: http://www.codinghorror.com/blog/archives/000818.html
•   Cash: http://www.flickr.com/photos/mindfire/315274981/
•   Steep: http://www.flickr.com/photos/worldofoddy/229501642/
•   Want You: http://www.flickr.com/photos/shutter/105497713/
•   Warn: http://www.flickr.com/photos/hugosimmelink/2252095723/
•   Questions: http://www.flickr.com/photos/seandreilinger/2326448445/

More Related Content

PDF
Concepts of Functional Programming for Java Brains (2010)
PDF
Prime Factors Code Kata (2010)
PDF
Designing Test Cases for the Gilded Rose Kata (2013)
PDF
Code Retreat Graz, Austria 2013
PDF
TDD as if You Meant It (2013)
PDF
Software Craftsmanship Journeyman Tour (2013)
PDF
The Brutal Refactoring Game (2013)
PDF
Code Quality Assurance v4 (2013)
Concepts of Functional Programming for Java Brains (2010)
Prime Factors Code Kata (2010)
Designing Test Cases for the Gilded Rose Kata (2013)
Code Retreat Graz, Austria 2013
TDD as if You Meant It (2013)
Software Craftsmanship Journeyman Tour (2013)
The Brutal Refactoring Game (2013)
Code Quality Assurance v4 (2013)

What's hot (20)

PDF
Deliberate Practice, New Learning Styles (2015)
PDF
Outside-in Test Driven Development - the London School of TDD
PDF
Coding Dojo: Naming with Dices (2021)
PDF
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
PDF
Designing Test Cases for the Gilded Rose Kata v2 (2015)
PDF
Coding Dojo: Functional Calisthenics (2016)
PDF
Coding Dojo: Baby Steps Push Challenge (2021)
PDF
Idiomatic R for Rosetta Code (2013)
PDF
Extract Method Refactoring Workshop (2016)
PDF
Deliberate Practice (Agile Slovenia 2015)
PDF
Prime Factors Code Kata - Practicing TDD (2014)
PDF
Coding Dojo: Bank OCR Outside-In (2015)
PDF
Clean Readable Specifications (ETC 2016)
PDF
Coding Dojo Object Calisthenics (2016)
PDF
JUnit Boot Camp (GeeCON 2016)
PDF
Brutal Coding Constraints (ITAKE 2017)
PDF
Writing Tests with the Unity Test Framework
PDF
Coding Dojo: Data Munging (2016)
PDF
Coding Dojo: Mars Rover (2014)
PDF
Coding Dojo: Adding Tests to Legacy Code (2014)
Deliberate Practice, New Learning Styles (2015)
Outside-in Test Driven Development - the London School of TDD
Coding Dojo: Naming with Dices (2021)
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Baby Steps Push Challenge (2021)
Idiomatic R for Rosetta Code (2013)
Extract Method Refactoring Workshop (2016)
Deliberate Practice (Agile Slovenia 2015)
Prime Factors Code Kata - Practicing TDD (2014)
Coding Dojo: Bank OCR Outside-In (2015)
Clean Readable Specifications (ETC 2016)
Coding Dojo Object Calisthenics (2016)
JUnit Boot Camp (GeeCON 2016)
Brutal Coding Constraints (ITAKE 2017)
Writing Tests with the Unity Test Framework
Coding Dojo: Data Munging (2016)
Coding Dojo: Mars Rover (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)
Ad

Similar to TDD and Related Techniques for Non Developers (2012) (20)

PPTX
Lean-Agile Development with SharePoint - Bill Ayers
PDF
CNUG TDD June 2014
PDF
Introduction to-automated-testing
PDF
Introduction to Automated Testing
PPTX
Topic production code
PPTX
TDD - Seriously, try it! (updated '22)
PPTX
Lecture3.se.pptx
PDF
Unit testing and code review
PPTX
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
PPTX
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
PDF
PPTX
Agile
PDF
Agile engineering practices
PPTX
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
PPTX
TDD - Seriously, try it! - Bucarest Tech Week
KEY
Driving application development through behavior driven development
PPTX
Test Driven Development & CI/CD
PDF
Introduction to Unit Tests and TDD
Lean-Agile Development with SharePoint - Bill Ayers
CNUG TDD June 2014
Introduction to-automated-testing
Introduction to Automated Testing
Topic production code
TDD - Seriously, try it! (updated '22)
Lecture3.se.pptx
Unit testing and code review
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Agile
Agile engineering practices
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
TDD - Seriously, try it! - Bucarest Tech Week
Driving application development through behavior driven development
Test Driven Development & CI/CD
Introduction to Unit Tests and TDD
Ad

More from Peter Kofler (13)

PDF
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
PDF
Refactoring the Tennis Kata v2 (2016)
PDF
Designing Test Cases for the Gilded Rose Kata v3 (2016)
PDF
Coding Dojo: Asynchronous Clock-In (2016)
PDF
Mob Programming (2016)
PDF
Code Retreat Venice (2016)
PDF
GDCR15 in Las Palmas, Gran Canaria
PDF
Pair Programming (2015)
PDF
Pragmatic Introduction to PHP Unit Testing (2015)
PDF
Coding Dojo: Fun with Tic-Tac-Toe (2014)
PDF
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
PDF
Code Refactoring - Live Coding Demo (JavaDay 2014)
PDF
Coding Dojo: Bank OCR (2014)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Refactoring the Tennis Kata v2 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Coding Dojo: Asynchronous Clock-In (2016)
Mob Programming (2016)
Code Retreat Venice (2016)
GDCR15 in Las Palmas, Gran Canaria
Pair Programming (2015)
Pragmatic Introduction to PHP Unit Testing (2015)
Coding Dojo: Fun with Tic-Tac-Toe (2014)
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)
Coding Dojo: Bank OCR (2014)

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation theory and applications.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
Encapsulation theory and applications.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

TDD and Related Techniques for Non Developers (2012)

  • 1. Test Driven Development and Related Techniques For Non-Developers ;-) IBM 2012 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.
  • 2. Peter Kofler • Ph.D. (Appl. Math.) • (Java) Software Developer • with IBM since 1 year • SDM Costing, IGA, GBS
  • 3. The opinions expressed here are my own and do not necessarily represent those of current or past employers.
  • 4. Agenda 1) What does it look like? 2) Why is it important? 3) What you need to do! 4) Summary
  • 5. 1) So what is it all about? The Prime Factors Kata (Demo)
  • 6. What Exactly Will We Do Now? ● write code together ● using TDD ● see techniques and patterns ● discuss while doing
  • 7. The Requirements. • Write a class named “PrimeFactors” that has one static method: generate. – The generate method takes an integer argument and returns a List<Integer>. – That list contains the prime factors in numerical sequence. http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata
  • 8. First Some Math. ● Prime Number: a natural number > 1 that has no divisors other than 1 and itself. ● e.g. 2, 3, 5, 61, 67, ..., 997, ..., 243112609-1, … ● Prime Factors: the prime numbers that divide an integer exactly without remainder. ● e.g. 2 = 2, 4 = 2 * 2, 24 = 2 * 2 * 2 * 3 288 = 25 * 32
  • 9. The Requirements (for Mortals). • code a file/module/class “PrimeFactors” • code a function/method/routine “generate” • accept an integer number as parameter • return the prime factors of that number
  • 11. Keep the bar green to keep the code clean.
  • 12. Unit Testing • test individual units • isolate each part • show that the individual parts are correct • regression testing • sort of living documentation • executed within a framework http://en.wikipedia.org/wiki/Unit_testing
  • 13. Test-Driven Development • add a test • run all tests and see if the new one fails • write some code • run all tests and see them succeed • refactor code mercilessly • „Red Green Refactor“ http://en.wikipedia.org/wiki/Test_Driven_Development
  • 14. A minute ago all their code worked
  • 15. Refactoring Refactoring is a technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. (Martin Fowler)
  • 16. Refactoring • small behavior preserving transformations • sequence of transformations produce a significant restructuring • each transformation is small, less likely to go wrong • system is kept fully working after each change • verified by working tests
  • 25. Continuous Integration • Maintain a code repository • Automate the build • Make the build self-testing • Everyone commits every day • Every commit should be built • Keep the build fast • Everyone can see the results of the build http://en.wikipedia.org/wiki/Continuous_integration
  • 26. Immediate Feedback and Early Warning
  • 28. 2) Why should we use TDD? • Writing tests takes time • and we need to deliver client value. I don't have time. I don't have time. I don't have time.
  • 29. Do you still use that one?
  • 30. Discussion • What do you think are the benefits of TDD? – rapid feedback –… – ...
  • 31. Benefits • speed up • coverage – measurable validation of correctness • quality – proven to save maintenance costs • creates a detailed specification
  • 32. Benefits • improve design – drive the design of a program – think in exposed API
  • 33. Problems • missing management buy-in • high ramp-up time • still need integration tests http://watirmelon.com/2012/01/31/introducing-the-software-testing-ice-cream-cone/
  • 34. TDD will not fix missing skills! • badly written tests – brittle – blinking – slow – duplicate code – maintenance burden – wrong abstractions – not really unit tests
  • 35. Because TDD is hard! • need to know OO, design, abstraction, ... • new style of thinking • need self-discipline • (learning curve)
  • 36. 3) What you need to do
  • 37. Problem Indicators: CI • blinking builds • builds broken for long time • increasing build execution time • decreasing code coverage
  • 38. Problem Indicators: Tests • slow • fragile • no detailed feedback • “Ice-Cream Cone”
  • 39. Problem Indicators: Developers • claiming that they can't write tests • claiming that they can't fix tests • wanting to delete tests
  • 40. “Buzzwords” Summary • Techniques – Unit Testing – Test Driven Development – Refactoring – Code Coverage – Continuous Integration • Management Buy-In • Keep an eye on the CI server
  • 41. Support TDD Do not compromise on techniques!
  • 43. Peter Kofler @codecopkofler www.code-cop.org
  • 44. CC Images • Drive: http://www.flickr.com/photos/hjem/367306587/ • Judge: http://www.flickr.com/photos/eldave/6169431454/ • List: http://www.flickr.com/photos/kylesteeddesign/3724074594/ • Question mark: http://www.flickr.com/photos/oberazzi/318947873/ • Fence: http://www.flickr.com/photos/30830597@N08/3630649274/ • Coverage: http://www.flickr.com/photos/paulk/3166328163/ • Works: http://www.codinghorror.com/blog/archives/000818.html • Cash: http://www.flickr.com/photos/mindfire/315274981/ • Steep: http://www.flickr.com/photos/worldofoddy/229501642/ • Want You: http://www.flickr.com/photos/shutter/105497713/ • Warn: http://www.flickr.com/photos/hugosimmelink/2252095723/ • Questions: http://www.flickr.com/photos/seandreilinger/2326448445/