Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
FAKE IT OUTSIDE-IN TDD
David Völkel
9th May @ Softwerkskammer Meetup Munich
@DAVIDVOELKEL
@codecentric
@softwerkskammer
#TDD
#software_design
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
INFLUENCES
2003 Kent Beck’s "Fake It" Pattern
2009 #GOOS’s "Outside-In" Design
2013 Emily Bache 

"Outside-In development ...
AGENDA
Theory
Building Blocks
Fake It Outside-In
Practice
Kata
Reflect
Retro
Trade-Offs
Discussion
BUILDING BLOCKS
INTEGRATION OPERATION
SEGREGATION PRINCIPLE
*"Integration Operation Segregation Principle", Ralf Westphal
"Die kniffligen ...
INTEGRATION OPERATION
SEGREGATION PRINCIPLE
public void sendDiscountMailingTo(String email) {
Customer customer = customer...
OPERATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(email);
Account ...
OPERATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(email);
Account ...
OPERATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(email);
Account ...
OPERATION
INTEGRATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(emai...
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(email);
String content = r...
OPERATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(email);
String c...
OPERATION
INTEGRATION
public void sendDiscountMailingTo(String email) {
Customer customer = customerDB.findCustomerBy(emai...
GREEN BAR PATTERNS*
Obvious Implementation
Fake it (until you make it)
Triangulation
* Kent Beck in "TDD by Example"
GREEN BAR PATTERNS
DEMO
GREEN BAR PATTERNS
Obvious Implementation
Fake it
Triangulation
Trade-Off
Complexity
SWEET SPOT
Logic
GREEN BAR PATTERNS
Obvious Implementation
Fake it
Triangulation
SWEET SPOT
Structure
Logic
GREEN BAR PATTERNS
Obvious Implementation
Fake it
Triangulation
SWEET SPOT
Trivial
Structure
Logic
GREEN BAR PATTERNS
Obvious Implementation
Fake it
Triangulation
INTEGRATION
OPERATION
Fake it
Triangulation
GREEN BAR PATTERNS
Structure
Logic
IOSP
INTER-OBJECT DESIGN
EMERGENT
INSIDE-OUT
OUTSIDE-IN & MOCKS
OUTSIDE-IN & FAKE IT
Acceptance Test
EMERGENT
Acceptance Test
EMERGENT
Acceptance Test
EMERGENT
Acceptance Test Design through
Refactoring
EMERGENT
Acceptance Test
EMERGENT
Acceptance Test
UI
Persistence
EMERGENT
UI df
Persistence nc.
Unit Test
INSIDE-OUT
nc.
Unit Test
INSIDE-OUT
Unit Test
INSIDE-OUT
Acceptance Test
INSIDE-OUT
Acceptance Test
UI
Persistence
OUTSIDE-IN
Unit test
Mock
OUTSIDE-IN & MOCKS
Unit Test
OUTSIDE-IN & MOCKS
Acceptance Test
UI
Persistence
OUTSIDE-IN & MOCKS
Comprehensive
Acceptance Test
OUTSIDE-IN & FAKE IT
Comprehensive
Acceptance Test
Faked Result
OUTSIDE-IN & FAKE IT
Acceptance Test
Fake
Fake
OUTSIDE-IN & FAKE IT
Acceptance Test Drive Structure
through Refactoring
OUTSIDE-IN & FAKE IT
OUTSIDE-IN & FAKE IT
Acceptance Test
Unit Test
Fill logic with
triangulation
OUTSIDE-IN & FAKE IT
Acceptance Test Unit Test
INTEGRATION
OUTSIDE-IN & FAKE IT
OPERATION
Fake It
Triangulation
Start with
• comprehensive 

Acceptance Test
• faked resu...
INTEGRATION
OUTSIDE-IN & FAKE IT
OPERATION
Fake It
Triangulation
Start with
• comprehensive 

Acceptance Test
• faked resu...
FAKE IT OUTSIDE-IN
DEMO
PREPARATORY REFACTORINGS*
*"An example of preparatory refactoring", Martin Fowler
"GREEN" PHASE
Implementation Run Test
"Green Phase"
LIMIT YOUR TIME IN RED
"Green Phase"
Implementation Run Test
Implementation Run TestPreparatory Refactoring
PREPARATORY REFACTORINGS
DEMO
FAKE-IT VARIANT
CALCULATE BACKWARDS
DEMO
PRACTICE
CODING SESSION
KATA
Diamond Kata
CODING SESSION
KATA
Diamond Kata
CONSTRAINTS
Start with comprehensive Acceptance Test & faked result
Drive structure by re...
RETROSPECTIVE
RETROSPECTIVE
Observations?
RETROSPECTIVE
Observations?
Strengths?
RETROSPECTIVE
Observations?
Strengths?
Weaknesses?
VSTRADE-OFFS
TDD APPROACHES
Design uncertainty Overhead if design clear
Only Integration Tests
EMERGENT
+ -
INSIDE-OUT
3rd Party Integration YAGNI Design Potential
+ -
OUTSIDE-IN & MOCKS
No YAGNI Design
Decoupled Classes
Interaction Complexity
Refactorability
+ -
OUTSIDE-IN & FAKE IT
No YAGNI &
No Mocks
Higher Coupling
Fake data easy to forget
Omitting cases is tempting
+ -
SWEET SPOTS
Triangulation Fake It
#Branches N 1
SWEET SPOTS
Triangulation Fake It
#Branches N 1
Structure Cumbersome Data guides well
SWEET SPOTS
Triangulation Fake It
#Branches N 1
Structure Cumbersome Data guides well
Baby Steps
Through Preparatory
Refac...
DISCUSSION
LICENSE
Creative Commons Attribution-ShareAlike 3.0
IMAGES
Most are Public Domain except theses
Creative Commons with attributions:
"Unstruttalbrücke" by Störfix
From State Li...
Nächste SlideShare
Wird geladen in …5
×

Fake It Outside-In TDD

152 Aufrufe

Veröffentlicht am

The slides of my Fake It Outside-In TDD session at Softwerkskammer Meetup Munich. Some improved screencasts you can find here: https://www.youtube.com/playlist?list=PL_ueet93U84VIy8O7U4dUV0GyGvuzFAt8

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Fake It Outside-In TDD

  1. 1. FAKE IT OUTSIDE-IN TDD David Völkel 9th May @ Softwerkskammer Meetup Munich
  2. 2. @DAVIDVOELKEL @codecentric @softwerkskammer #TDD #software_design
  3. 3. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" 2014 Justin Searls "The Failures of 'Intro to TDD'" COMBINATION 2015 Dimitry Polivaev Outside-In with faked Data 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  4. 4. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" 2014 Justin Searls "The Failures of 'Intro to TDD'" COMBINATION 2015 Dimitry Polivaev Outside-In with faked Data 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  5. 5. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" 2014 Justin Searls "The Failures of 'Intro to TDD'" COMBINATION 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  6. 6. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" 2014 Justin Searls "The Failures of 'Intro to TDD'" COMBINATION 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  7. 7. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" COMBINATION 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  8. 8. INFLUENCES 2003 Kent Beck’s "Fake It" Pattern 2009 #GOOS’s "Outside-In" Design 2013 Emily Bache 
 "Outside-In development with Double Loop TDD" 2014 Justin Searls "The Failures of 'Intro to TDD'" COMBINATION 2016 SoCraTes DE Outside-In Fake It Session 2017 Refinement
  9. 9. AGENDA Theory Building Blocks Fake It Outside-In Practice Kata Reflect Retro Trade-Offs Discussion
  10. 10. BUILDING BLOCKS
  11. 11. INTEGRATION OPERATION SEGREGATION PRINCIPLE *"Integration Operation Segregation Principle", Ralf Westphal "Die kniffligen Fälle beim Testen - Sichtbarkeit", Stefan Lieser *
  12. 12. INTEGRATION OPERATION SEGREGATION PRINCIPLE public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); Account account = customer.account(); String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; String content = "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; mailService.sendMail(email, content); }
  13. 13. OPERATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); Account account = customer.account(); String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; String content = "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; mailService.sendMail(email, content); } INTEGRATION OPERATION SEGREGATION PRINCIPLE
  14. 14. OPERATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); Account account = customer.account(); String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; String content = "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; mailService.sendMail(email, content); } INTEGRATION OPERATION SEGREGATION PRINCIPLE INTEGRATION INTEGRATION
  15. 15. OPERATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); Account account = customer.account(); String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; String content = "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; mailService.sendMail(email, content); } INTEGRATION OPERATION SEGREGATION PRINCIPLE INTEGRATION INTEGRATION
  16. 16. OPERATION INTEGRATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); String content = renderMessage(customer, customer.account()); mailService.sendMail(email, content); } private String renderMessage(Customer customer, Account account) { String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; return "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; } INTEGRATION OPERATION SEGREGATION PRINCIPLE
  17. 17. public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); String content = renderMessage(customer, customer.account()); mailService.sendMail(email, content); } private String renderMessage(Customer customer, Account account) { String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; return "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; } TESTS?
  18. 18. OPERATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); String content = renderMessage(customer, customer.account()); mailService.sendMail(email, content); } private String renderMessage(Customer customer, Account account) { String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; return "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; } TESTS? N UNITTESTS
  19. 19. OPERATION INTEGRATION public void sendDiscountMailingTo(String email) { Customer customer = customerDB.findCustomerBy(email); String content = renderMessage(customer, customer.account()); mailService.sendMail(email, content); } private String renderMessage(Customer customer, Account account) { String discount = account == FREE ? "no" : account == BASE ? "a 10%" : account == PREMIUM ? "a 25%" : "-ERROR-"; return "Hello " + customer.getName() + ",nn" + "This week you get " + discount + " discount " + "on all our products.nn" + "Best Regards,n" + "ACME Customer Service"; } TESTS?1 INTEGRATION TEST N UNITTESTS
  20. 20. GREEN BAR PATTERNS* Obvious Implementation Fake it (until you make it) Triangulation * Kent Beck in "TDD by Example"
  21. 21. GREEN BAR PATTERNS DEMO
  22. 22. GREEN BAR PATTERNS Obvious Implementation Fake it Triangulation Trade-Off Complexity
  23. 23. SWEET SPOT Logic GREEN BAR PATTERNS Obvious Implementation Fake it Triangulation
  24. 24. SWEET SPOT Structure Logic GREEN BAR PATTERNS Obvious Implementation Fake it Triangulation
  25. 25. SWEET SPOT Trivial Structure Logic GREEN BAR PATTERNS Obvious Implementation Fake it Triangulation
  26. 26. INTEGRATION OPERATION Fake it Triangulation GREEN BAR PATTERNS Structure Logic IOSP
  27. 27. INTER-OBJECT DESIGN EMERGENT INSIDE-OUT OUTSIDE-IN & MOCKS OUTSIDE-IN & FAKE IT
  28. 28. Acceptance Test EMERGENT
  29. 29. Acceptance Test EMERGENT
  30. 30. Acceptance Test EMERGENT
  31. 31. Acceptance Test Design through Refactoring EMERGENT
  32. 32. Acceptance Test EMERGENT
  33. 33. Acceptance Test UI Persistence EMERGENT
  34. 34. UI df Persistence nc. Unit Test INSIDE-OUT
  35. 35. nc. Unit Test INSIDE-OUT
  36. 36. Unit Test INSIDE-OUT
  37. 37. Acceptance Test INSIDE-OUT
  38. 38. Acceptance Test UI Persistence OUTSIDE-IN
  39. 39. Unit test Mock OUTSIDE-IN & MOCKS
  40. 40. Unit Test OUTSIDE-IN & MOCKS
  41. 41. Acceptance Test UI Persistence OUTSIDE-IN & MOCKS
  42. 42. Comprehensive Acceptance Test OUTSIDE-IN & FAKE IT
  43. 43. Comprehensive Acceptance Test Faked Result OUTSIDE-IN & FAKE IT
  44. 44. Acceptance Test Fake Fake OUTSIDE-IN & FAKE IT
  45. 45. Acceptance Test Drive Structure through Refactoring OUTSIDE-IN & FAKE IT
  46. 46. OUTSIDE-IN & FAKE IT Acceptance Test Unit Test Fill logic with triangulation
  47. 47. OUTSIDE-IN & FAKE IT Acceptance Test Unit Test
  48. 48. INTEGRATION OUTSIDE-IN & FAKE IT OPERATION Fake It Triangulation Start with • comprehensive 
 Acceptance Test • faked result Drive structure by refactoring Drive logic by unit tests
  49. 49. INTEGRATION OUTSIDE-IN & FAKE IT OPERATION Fake It Triangulation Start with • comprehensive 
 Acceptance Test • faked result Drive structure by refactoring Drive logic by unit tests
  50. 50. FAKE IT OUTSIDE-IN DEMO
  51. 51. PREPARATORY REFACTORINGS* *"An example of preparatory refactoring", Martin Fowler
  52. 52. "GREEN" PHASE Implementation Run Test "Green Phase"
  53. 53. LIMIT YOUR TIME IN RED "Green Phase" Implementation Run Test Implementation Run TestPreparatory Refactoring
  54. 54. PREPARATORY REFACTORINGS DEMO
  55. 55. FAKE-IT VARIANT CALCULATE BACKWARDS DEMO
  56. 56. PRACTICE
  57. 57. CODING SESSION KATA Diamond Kata
  58. 58. CODING SESSION KATA Diamond Kata CONSTRAINTS Start with comprehensive Acceptance Test & faked result Drive structure by refactoring Drive conditionals by unit tests & triangulation
  59. 59. RETROSPECTIVE
  60. 60. RETROSPECTIVE Observations?
  61. 61. RETROSPECTIVE Observations? Strengths?
  62. 62. RETROSPECTIVE Observations? Strengths? Weaknesses?
  63. 63. VSTRADE-OFFS TDD APPROACHES
  64. 64. Design uncertainty Overhead if design clear Only Integration Tests EMERGENT + -
  65. 65. INSIDE-OUT 3rd Party Integration YAGNI Design Potential + -
  66. 66. OUTSIDE-IN & MOCKS No YAGNI Design Decoupled Classes Interaction Complexity Refactorability + -
  67. 67. OUTSIDE-IN & FAKE IT No YAGNI & No Mocks Higher Coupling Fake data easy to forget Omitting cases is tempting + -
  68. 68. SWEET SPOTS Triangulation Fake It #Branches N 1
  69. 69. SWEET SPOTS Triangulation Fake It #Branches N 1 Structure Cumbersome Data guides well
  70. 70. SWEET SPOTS Triangulation Fake It #Branches N 1 Structure Cumbersome Data guides well Baby Steps Through Preparatory Refactorings Easy
  71. 71. DISCUSSION
  72. 72. LICENSE Creative Commons Attribution-ShareAlike 3.0
  73. 73. IMAGES Most are Public Domain except theses Creative Commons with attributions: "Unstruttalbrücke" by Störfix From State Library of Queensland

×