Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Red, green,
… what now?!
@kevinrutherford
@jjeffries1
Primitive Obsession
Feature Envy
Sim
ulated
Polym
orphism
Lazy Class
Temporary Field
Inappropriate Intimacy
ShotgunSurgery...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Connascence of ...
Scanning a
single item
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:CoEO
scan()scan()
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
CoV
CoEO
scan()sc...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:CoEO
CoM
scan()sca...
Checkout with
an empty basket
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
CoM
int
int
int
u...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
CoM
int
int
int
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
Different items
have different
prices
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
string string
CoM
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
string string
bal...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
“A”“A”
string str...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
CoV
“A”“A”
3030
s...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
“A”“A”
string str...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
string string
bal...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
string string
CoM...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Test: Code:
Recap
Scanning a
single item
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Scanning has no
effect on the...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce
Parameter{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Scanning has no
effect on the...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Write a test{
Checkout with
an empty basket
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Everyone knows we use
an int ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce @Before
block{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Everyone knows we use
an int ...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce Money class{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Different items
have different
prices
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
balance.add()
called twice
St...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce
Parameter{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
balance.add()
called twice
St...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce
Parameter{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
balance.add()
called twice
St...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce a Map of
names to p...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Strings used to
represent pro...
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce
PriceList{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Introduce
ProductCode{
Name
Type
Meaning
Algorithm
Position
Execution Order
Timing
Value
Identity
1
2
3
4
5
6
7
8
9
Red, green,
… what now?!
@kevinrutherford
@jjeffries1
Red, green, ... what now?!
Red, green, ... what now?!
Red, green, ... what now?!
Red, green, ... what now?!
Red, green, ... what now?!
Red, green, ... what now?!
Upcoming SlideShare
Loading in …5
×

Red, green, ... what now?!

1,838 views

Published on

A tour of @pragdave's Checkout kata, using connascence to guide the refactoring steps. Presented at Agile Manchester 2015.

Published in: Software

Red, green, ... what now?!

  1. 1. Red, green, … what now?! @kevinrutherford @jjeffries1
  2. 2. Primitive Obsession Feature Envy Sim ulated Polym orphism Lazy Class Temporary Field Inappropriate Intimacy ShotgunSurgery Data Clump Long M ethod Large Class ??? ??? ??? ??? ??? ??? ??? RefusedBequest
  3. 3. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  4. 4. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  5. 5. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  6. 6. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  7. 7. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  8. 8. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  9. 9. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  10. 10. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  11. 11. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  12. 12. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Connascence of ...
  13. 13. Scanning a single item
  14. 14. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code:
  15. 15. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code:CoEO scan()scan()
  16. 16. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: CoV CoEO scan()scan() 5050
  17. 17. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code:CoEO CoM scan()scan() int int int
  18. 18. Checkout with an empty basket
  19. 19. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: CoM int int int unitPrice = 50 unitPrice = 50 int CoA
  20. 20. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: CoM int int int
  21. 21. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code:
  22. 22. Different items have different prices
  23. 23. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: string string CoM
  24. 24. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: string string balance.add() balance.add() CoM CoA
  25. 25. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: “A”“A” string string balance.add() balance.add() CoV CoM CoA
  26. 26. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: CoV “A”“A” 3030 string string balance.add() balance.add() CoV CoM CoA
  27. 27. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: “A”“A” string string balance.add() balance.add() CoV CoM CoA Money, MoneyMoney, Money CoP
  28. 28. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: string string balance.add() balance.add() CoM CoA Money, MoneyMoney, Money CoP
  29. 29. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code: string string CoM Map Map CoM
  30. 30. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Test: Code:
  31. 31. Recap
  32. 32. Scanning a single item
  33. 33. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Scanning has no effect on the balance Both classes know the price = 50
  34. 34. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce Parameter{
  35. 35. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Scanning has no effect on the balance Everyone knows we use an int to represent money
  36. 36. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Write a test{
  37. 37. Checkout with an empty basket
  38. 38. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Everyone knows we use an int to represent money Common test setup
  39. 39. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce @Before block{
  40. 40. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Everyone knows we use an int to represent money
  41. 41. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce Money class{
  42. 42. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9
  43. 43. Different items have different prices
  44. 44. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 balance.add() called twice Strings used to represent product codes Everyone depends on “A” Everyone knows the price of “B”
  45. 45. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce Parameter{
  46. 46. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 balance.add() called twice Strings used to represent product codes Everyone depends on “A” Constructor parameters are indistinguishable
  47. 47. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce Parameter{
  48. 48. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 balance.add() called twice Strings used to represent product codes Constructor parameters are indistinguishable
  49. 49. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce a Map of names to prices{
  50. 50. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Strings used to represent product codes Map used to represent the price list
  51. 51. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce PriceList{
  52. 52. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9 Introduce ProductCode{
  53. 53. Name Type Meaning Algorithm Position Execution Order Timing Value Identity 1 2 3 4 5 6 7 8 9
  54. 54. Red, green, … what now?! @kevinrutherford @jjeffries1

×