SlideShare a Scribd company logo
1 of 26
Transformation Priority Premise:
TDD Test Order Matters
Mike Clement
@mdclement
mike@softwareontheside.com
http://blog.softwareontheside.com
http://agilecodegames.com
XP Simple Design
• Passes all tests
• Clear, expressive, consistent
• No duplication
• Minimal
TDD Review
TDD
• Red
• Green
• Refactor
Ways to get Green
• Fake it
• Obvious
implementation
• Triangulation
Example Transformations
• ({}–>nil) no code at all->code that employs nil
• (nil->constant)
• (variable->assignment) replacing the value of
a variable.
• (statement->statements) adding more
unconditional statements.
Uncle Bob’s Three Laws of TDD
• You are not allowed to write any production
code unless it is to make a failing unit test
pass.
• You are not allowed to write any more of a
unit test than is sufficient to fail; and
compilation failures are failures.
• You are not allowed to write any more
production code than is sufficient to pass the
one failing unit test.
Rule of
Perpetual
Inconsequence
Proposed Transformations
• ({}–>nil) no code at all->code that employs nil
• (nil->constant)
• (constant->constant+) a simple constant to a more complex constant
• (constant->scalar) replacing a constant with a variable or an argument
• (statement->statements) adding more unconditional statements.
• (unconditional->if) splitting the execution path
• (scalar->array)
• (array->container)
• (statement->recursion)
• (if->while)
• (expression->function) replacing an expression with a function or
algorithm
• (variable->assignment) replacing the value of a variable.
WORD WRAP
A Fork in the Road
Problem definition
• function named Wrap that takes two
arguments, a string, and a column number
• The function returns the string, but with line
breaks ('n') inserted at just the right places
to make sure that no line is longer than the
column number.
• Try to break lines at word boundaries.
LET’S CODE!
"I can't seem to get this test
to pass without writing a lot
of untested code."
They are the wrong tests,
because you could not figure
out how to pass them.
"[W]hen faced with a
problem you do not
understand, do any part of it
you do understand, then
look at it again."
The Premise Applied
• Prefer higher priority transformations.
• Choose tests that can be passed with higher
priority transformations.
• When a low priority transformation seems
required, backtrack to see if there is a simpler
test to pass.
WHAT ABOUT SOLUTION QUALITY?
Sorting Algorithms
The Premise Applied
• Prefer higher priority transformations.
• Choose tests that can be passed with higher
priority transformations.
• When a low priority transformation seems
required, backtrack to see if there is a simpler
test to pass.
Proposed Prioritized Transformations
• ({}–>nil) no code at all->code that employs nil
• (nil->constant)
• (constant->constant+) a simple constant to a more complex constant
• (constant->scalar) replacing a constant with a variable or an argument
• (statement->statements) adding more unconditional statements.
• (unconditional->if) splitting the execution path
• (scalar->array)
• (array->container)
• (statement->recursion)
• (if->while)
• (expression->function) replacing an expression with a function or
algorithm
• (variable->assignment) replacing the value of a variable.
ABSOLUTE PRIORITY PREMISE
“Cousin” Micah
Action Items!
• Read the original post
http://cleancoder.posterous.com/the-transformation-
priority-premise
• Sorting: http://cleancoder.posterous.com/transformation-
priority-and-sorting
• Fibonacci: http://cleancoder.posterous.com/fib-the-
transformation-priority-premise
• Flash Card: http://cleancoder.posterous.com/flash-tpp
• Uncle Bob on TPP: https://vimeo.com/60561303
• “Cousin” Micah on APP: https://vimeo.com/57851350 and
https://vimeo.com/59265614
• Experiment!
Software Craftsmanship!
• Participate in a local Software Craftsmanship
group wherever home is for you.
My Contact Info
• @mdclement
• mike@softwareontheside.com
• http://blog.softwareontheside.com
• http://agilecodegames.com
• Utah Software Craftsmanship Group
– http://utahsc.org
– @utahsc

More Related Content

What's hot

Unit testing
Unit testingUnit testing
Unit testing
Brian Hu
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide
vitalipe
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
Tomaš Maconko
 

What's hot (16)

Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
Unit testing
Unit testingUnit testing
Unit testing
 
How engineering practices help business
How engineering practices help businessHow engineering practices help business
How engineering practices help business
 
Refactoring
RefactoringRefactoring
Refactoring
 
How good are your tests?
How good are your tests?How good are your tests?
How good are your tests?
 
QA Evening Максим Колотилкин - Test State Pattern
QA Evening Максим Колотилкин - Test State PatternQA Evening Максим Колотилкин - Test State Pattern
QA Evening Максим Колотилкин - Test State Pattern
 
Testing - Is This Even a Thing?
Testing - Is This Even a Thing?Testing - Is This Even a Thing?
Testing - Is This Even a Thing?
 
Automated Testing but like for PowerShell (April 2012)
Automated Testing but like for PowerShell (April 2012)Automated Testing but like for PowerShell (April 2012)
Automated Testing but like for PowerShell (April 2012)
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide
 
Giving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at ListingsGiving automated tests the love they deserve at Listings
Giving automated tests the love they deserve at Listings
 
Swift testing ftw
Swift testing ftwSwift testing ftw
Swift testing ftw
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
IntroTestMore
IntroTestMoreIntroTestMore
IntroTestMore
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 

Viewers also liked

Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
Mike Clement
 
FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided Kata
Mike Clement
 

Viewers also liked (10)

Thinking in F#
Thinking in F#Thinking in F#
Thinking in F#
 
Put the Tests Before the Code
Put the Tests Before the CodePut the Tests Before the Code
Put the Tests Before the Code
 
Using Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit TestingUsing Rhino Mocks for Effective Unit Testing
Using Rhino Mocks for Effective Unit Testing
 
Software Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code GamesSoftware Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code Games
 
Play to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and DicePlay to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and Dice
 
Power of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) PatternsPower of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) Patterns
 
FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided Kata
 
The Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at PluralsightThe Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at Pluralsight
 
Mob Programming for Continuous Learning
Mob Programming for Continuous LearningMob Programming for Continuous Learning
Mob Programming for Continuous Learning
 
NATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platformsNATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platforms
 

Similar to Transformation Priority Premise: TDD Test Order Matters

Unit Testing
Unit TestingUnit Testing
Unit Testing
Adam Birr
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
Meilan Ou
 

Similar to Transformation Priority Premise: TDD Test Order Matters (20)

Transformation Priority Premise @Softwerkskammer MUC
Transformation Priority Premise @Softwerkskammer MUCTransformation Priority Premise @Softwerkskammer MUC
Transformation Priority Premise @Softwerkskammer MUC
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
Tdd guide
Tdd guideTdd guide
Tdd guide
 
Craftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding KataCraftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding Kata
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
TDD In Practice
TDD In PracticeTDD In Practice
TDD In Practice
 
Every code coverage tool is measuring the wrong thing (on purpose)
Every code coverage tool is measuring the wrong thing (on purpose)Every code coverage tool is measuring the wrong thing (on purpose)
Every code coverage tool is measuring the wrong thing (on purpose)
 
Practical TDD Demonstrated
Practical TDD DemonstratedPractical TDD Demonstrated
Practical TDD Demonstrated
 
Software testing with examples in Angular (and AngularJS)
Software testing with examples in Angular (and AngularJS)Software testing with examples in Angular (and AngularJS)
Software testing with examples in Angular (and AngularJS)
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Tdd practices
Tdd practicesTdd practices
Tdd practices
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
Unit Testing talk
Unit Testing talkUnit Testing talk
Unit Testing talk
 
Writing Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designsWriting Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designs
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Tdd red-green-refactor
Tdd red-green-refactorTdd red-green-refactor
Tdd red-green-refactor
 
Introducción a TDD
Introducción a TDDIntroducción a TDD
Introducción a TDD
 
Bigger Unit Test Are Better
Bigger Unit Test Are BetterBigger Unit Test Are Better
Bigger Unit Test Are Better
 

More from Mike Clement

Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
Mike Clement
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# Adapted
Mike Clement
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
Mike Clement
 

More from Mike Clement (11)

Collaboration Principles from Mob Programming
Collaboration Principles from Mob ProgrammingCollaboration Principles from Mob Programming
Collaboration Principles from Mob Programming
 
Focus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in ActionFocus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in Action
 
Taming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touchTaming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touch
 
Develop your sense of code smell
Develop your sense of code smellDevelop your sense of code smell
Develop your sense of code smell
 
Maps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big PictureMaps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big Picture
 
Escaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product DevelopmentEscaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product Development
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
 
Linq (from the inside)
Linq (from the inside)Linq (from the inside)
Linq (from the inside)
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# Adapted
 
Code Katas: Practicing Your Craft
Code Katas: Practicing Your CraftCode Katas: Practicing Your Craft
Code Katas: Practicing Your Craft
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

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
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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)
 
[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
 

Transformation Priority Premise: TDD Test Order Matters

  • 1. Transformation Priority Premise: TDD Test Order Matters Mike Clement @mdclement mike@softwareontheside.com http://blog.softwareontheside.com http://agilecodegames.com
  • 2. XP Simple Design • Passes all tests • Clear, expressive, consistent • No duplication • Minimal
  • 3. TDD Review TDD • Red • Green • Refactor Ways to get Green • Fake it • Obvious implementation • Triangulation
  • 4.
  • 5.
  • 6.
  • 7. Example Transformations • ({}–>nil) no code at all->code that employs nil • (nil->constant) • (variable->assignment) replacing the value of a variable. • (statement->statements) adding more unconditional statements.
  • 8. Uncle Bob’s Three Laws of TDD • You are not allowed to write any production code unless it is to make a failing unit test pass. • You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. • You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
  • 10. Proposed Transformations • ({}–>nil) no code at all->code that employs nil • (nil->constant) • (constant->constant+) a simple constant to a more complex constant • (constant->scalar) replacing a constant with a variable or an argument • (statement->statements) adding more unconditional statements. • (unconditional->if) splitting the execution path • (scalar->array) • (array->container) • (statement->recursion) • (if->while) • (expression->function) replacing an expression with a function or algorithm • (variable->assignment) replacing the value of a variable.
  • 11. WORD WRAP A Fork in the Road
  • 12. Problem definition • function named Wrap that takes two arguments, a string, and a column number • The function returns the string, but with line breaks ('n') inserted at just the right places to make sure that no line is longer than the column number. • Try to break lines at word boundaries.
  • 14.
  • 15. "I can't seem to get this test to pass without writing a lot of untested code."
  • 16. They are the wrong tests, because you could not figure out how to pass them.
  • 17. "[W]hen faced with a problem you do not understand, do any part of it you do understand, then look at it again."
  • 18.
  • 19. The Premise Applied • Prefer higher priority transformations. • Choose tests that can be passed with higher priority transformations. • When a low priority transformation seems required, backtrack to see if there is a simpler test to pass.
  • 20. WHAT ABOUT SOLUTION QUALITY? Sorting Algorithms
  • 21. The Premise Applied • Prefer higher priority transformations. • Choose tests that can be passed with higher priority transformations. • When a low priority transformation seems required, backtrack to see if there is a simpler test to pass.
  • 22. Proposed Prioritized Transformations • ({}–>nil) no code at all->code that employs nil • (nil->constant) • (constant->constant+) a simple constant to a more complex constant • (constant->scalar) replacing a constant with a variable or an argument • (statement->statements) adding more unconditional statements. • (unconditional->if) splitting the execution path • (scalar->array) • (array->container) • (statement->recursion) • (if->while) • (expression->function) replacing an expression with a function or algorithm • (variable->assignment) replacing the value of a variable.
  • 24. Action Items! • Read the original post http://cleancoder.posterous.com/the-transformation- priority-premise • Sorting: http://cleancoder.posterous.com/transformation- priority-and-sorting • Fibonacci: http://cleancoder.posterous.com/fib-the- transformation-priority-premise • Flash Card: http://cleancoder.posterous.com/flash-tpp • Uncle Bob on TPP: https://vimeo.com/60561303 • “Cousin” Micah on APP: https://vimeo.com/57851350 and https://vimeo.com/59265614 • Experiment!
  • 25. Software Craftsmanship! • Participate in a local Software Craftsmanship group wherever home is for you.
  • 26. My Contact Info • @mdclement • mike@softwareontheside.com • http://blog.softwareontheside.com • http://agilecodegames.com • Utah Software Craftsmanship Group – http://utahsc.org – @utahsc

Editor's Notes

  1. Familiarity with TDDFamiliarity with Principles of Simple Design
  2. Where’s the love?There’s been an assumption that this is “regular” programming.
  3. Code has mass, some constructs have more mass than others