SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

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

Hinweis der Redaktion

  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