Pro Yearly is on sale from $80 to $50! »

Developer on Detox

Developer on Detox

Let’s meet John Craft - a great software craftsman. Today is his last day at work before long holidays. John has just given his functionality to review and wants to leave at 6:00 PM.

This is a story of a code review, in which the reviewer found a few unfortunate issues at the worst possible time - 5 minutes before the holidays.

Let’s put ourselves in John’s shoes and try to decide what is the best solution for a true craftsman, who is interested in both quality and good design. I will talk about illusions, intuition, and decision making.

6f6dc1b13fd3fe35d36db3adafcb0c8e?s=128

Michał Płachta

February 25, 2017
Tweet

Transcript

  1. @miciek Michał Płachta Developer on DETOX www.michalplachta.com

  2. @miciek Meet John Craft

  3. @miciek John Learns… All The Time

  4. @miciek John Pair Programs

  5. @miciek John uses TDD

  6. @miciek John Monitors Tests Stability

  7. @miciek John Uses Simple Design Passes Tests Reveals Intention No

    Duplication Fewest Elements
  8. @miciek John Uses Monitoring

  9. @miciek John Loves Code Reviews

  10. @miciek John Cares About Cycle Time Idea Happy User

  11. @miciek John Is Software Craftsman

  12. @miciek John Aspires To Be An Artist 2MB RAM

  13. @miciek vs Craftsman Artist

  14. @miciek vs vs Craftsman Artist Human

  15. @miciek The Friday’s Standup

  16. @miciek The Story Of The Story Standup Review Started

  17. @miciek What Would You Do? stay until names are fixed

    ask the team to finish merge change add “fix names” to backlog leave and continue when you’re back
  18. @miciek vs vs Choice Craftsman Artist Human stay until names

    are fixed leave continue when you’re back ask the team to finish merge change add “fix names” to backlog
  19. @miciek Decision Paralysis

  20. @miciek John Uses Intuition

  21. @miciek Doctor Satisfaction Chabris, Simons - “The Invisible Gorilla: How

    Our Intuitions Deceive Us”, p. 106 Doctor A Doctor B Doctor C Doctor D said nothing expressed uncertainty “You have nothing to lose” consulted a book prescribed antibiotics prescribed antibiotics prescribed antibiotics prescribed antibiotics Lowest perceived satisfaction! OMG! He consulted a book! We’re doomed!
  22. @miciek Illusion Of Confidence http://redonline.cdnds.net/main/thumbs/18472/george-clooney-dr-doug-er-pictures-tv-shows-redonline.co.uk.jpg

  23. @miciek Trivia Quiz Chabris, Simons - “The Invisible Gorilla: How

    Our Intuitions Deceive Us”, p. 100 Question #1 True or False? Question #1 True or False? Question #1 True or False? Question #1 True or False? Question #1 True or False? Your Confidence [50-100%]
  24. @miciek Trivia Test Confidence Chabris, Simons - “The Invisible Gorilla:

    How Our Intuitions Deceive Us”, p. 100 Question #1 True or False? Question #1 True or False? Question #1 True or False? Question #1 True or False? Question #1 True or False? Your Confidence [50-100%] 60% average correctness 75% average confidence
  25. @miciek Chabris, Simons - “The Invisible Gorilla: How Our Intuitions

    Deceive Us”, p. 100 Few Weeks Later... A Second Test Different Questions 90% confident people were the same I have a confident character! but still only 60% average correctness
  26. @miciek “ Confidence appears to be a consistent quality [...]

    that has relatively little to do with one’s knowledge or mental ability. - Chabris, Simons Chabris, Simons - “The Invisible Gorilla: How Our Intuitions Deceive Us”, p. 101
  27. @miciek Illusion Of Knowledge I use it every day! I

    know how it works! therefore
  28. @miciek Quiz: How Does It Work? ▪ car speed meter?

    ▪ zipper? ▪ toilet? ▪ piano key? ▪ sewing machine? ▪ bike? rate your understanding 1-7 Chabris, Simons - “The Invisible Gorilla: How Our Intuitions Deceive Us”, p. 120
  29. @miciek How Does A Bike Work? 4.5/7 average reported understanding

    https://www.dezeen.com/2016/06/19/velocipedia-project-hopeless-bicycle-drawings-life-digital-renders-gianluca-gimini/
  30. @miciek Illusion of Confidence + Illusion of Knowledge = Opinion

  31. @miciek Dealing With Illusions Why? Why? Why? Why? Why?

  32. @miciek Why Does Bike Work? Why? Why? Why? Why? Why?

    Cyclist uses pedals to make the bike move and steering wheel to steer. Why do pedals make the bike move?
  33. @miciek Why Do Pedals Make The Bike Move? Why? Why?

    Why? Why? Why? Pedals are connected with the chain drive which transmits the mechanical power and moves the wheels. Why do wheels move without falling?
  34. @miciek Why Do Wheels Move Without Falling? Why? Why? Why?

    Why? Why? Thanks to the steering axis angle. Why is the steering axis angle so important?
  35. @miciek Why Is Steering Axis Angle So Important? Why? Why?

    Why? Why? Why? Why don’t bikes fall when turning? http://www.fiztaszki.pl/node/56 Thanks to the trail.
  36. @miciek Why Don’t Bikes Fall When Turning? Why? Why? Why?

    Why? Why? https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Tuftscriterium.jpg/728px-Tuftscriterium.jpg Thanks to the centrifugal force.
  37. @miciek Developer’s Opinions tests are very important standups should be

    done every day open space are good for collaboration good names make the code readable Oh Yes!
  38. @miciek John Was Under Influence of Illusions

  39. @miciek Developer DETOX on “ Whenever I make a decision

    based on intuition, I state it openly and humbly. I am aware of my limitations. John - Humble Developer
  40. @miciek Developer DETOX on Doesn’t say ▪ “This is a

    good practice…” ▪ “This is an antipattern…” ▪ “Uncle Bob said that…” ▪ “Everybody knows that…” ▪ “This is prerequisite for having a clean code...” ▪ “This is not advised...”
  41. @miciek Any Alternatives? decisions based on data well-designed experiments evaluative

    research papers
  42. @miciek Agenda Intuition & Illusions Example: Names Example: Backlog DETOX

    before DETOX after
  43. @miciek What Would Developer On Detox Do? stay until names

    are fixed ask the team to finish merge change add “fix names” to backlog leave and continue when you’re back
  44. @miciek Let’s Do Some Research!

  45. @miciek “ There are only two hard things in Computer

    Science: cache invalidation and naming things. - Phil Karlton
  46. @miciek The Good, The Bad and The Ugly... Name I

    am writing the code “Names look good” I am reviewing someone’s code “Names look bad/ugly” …because it’s a prerequisite to understand the rest! …or I don’t pay attention because I am focusing on concepts & design
  47. @miciek Most Serious Problems LaToza, Venolia, DeLine - “Maintaining Mental

    Models: A Study of Developer Work Habits” This is a serious problem for me % agree “Understanding the rationale behind a piece of code” 66% “Understanding code that someone else wrote” 56% “Understanding the history of a piece of code” 51%
  48. @miciek Most Serious Problems LaToza, Venolia, DeLine - “Maintaining Mental

    Models: A Study of Developer Work Habits” This is a serious problem for me % agree “Understanding the rationale behind a piece of code” 66% “Understanding code that someone else wrote” 56% “Understanding the history of a piece of code” 51% 17% “Understanding a piece of code written by me”
  49. @miciek Names are ~70% Identifiers Keywords Delimiters Operators Literals 70%

    30% (based on data from Eclipse 3.0M7, Tomcat 5.0.30, Sun JDK 1.4.2) / Deißenböck, Pizka - “Concise and Consistent Naming”
  50. @miciek Dealing With Naming Problem Robert Martin - “Clean Code”

    “use intention-revealing names" “avoid disinformation" “make meaningful distinctions” “use pronounceable names” “use searchable names” “avoid encodings” “don't be cute” “don't pun” “pick one word per concept” “use solution domain names” “use problem domain names” “add meaningful context”
  51. @miciek Cargo Cult Of Naming Conventions intention-revealing avoid meaningful use

    use avoid don't don't one word use use meaningful But what does meaningful even mean?
  52. @miciek Difference Of Opinion “ 7-18% chance that two people

    apply the same name to an object* ...a name not only needs to be meaningful but reflect the correct meaning. Second, the “correct” meaning and name of a concept is naturally highly debatable. - Deißenböck, Pizka *G. Butler, P. Grogono, R. Shinghal, and I. Tjandra. Retrieving information from data flow diagrams. In Working Conference on Reverse Engineering, pages 84–93, November 1995.
  53. @miciek n1 Identifier Names (N) Concepts (C) n1 c1 c2

    n2 Identifier Naming Formally ... all identifiers found in the source code ... all concepts related to the project & team R concept c1 is represented by n2 in the code Deißenböck, Pizka - “Concise and Consistent Naming”
  54. @miciek n1 Identifier Names (N) Concepts (C) book to book

    a book number accountNumber an account number a phone number Homonyms & Synonyms
  55. @miciek n1 Identifier Names (N) Concepts (C) book reserve to

    book reserve a book number phoneNumber accountNumber an account number a phone number Renaming and Code Decay
  56. @miciek Keeping Up With All The Names Deißenböck, Pizka -

    “Concise and Consistent Naming” Project # identifiers # words Eclipse 3.0M7 94,829 7,233 Sun’s JDK 1.4.2 42,869 6,426 Tomcat 5.0.30 11,656 2,587 About half as much as Oxford Advanced Learner’s Dictionary examples: frag, fragement, fragment, fragmentation, fragmented, fragmentname, fragments, frags
  57. @miciek n1 Identifier Names (N) Concepts (C) reserve reserve book

    phoneNumber accountNumber account number phone number Control The Concept Space! book Deißenböck, Pizka - “Concise and Consistent Naming”
  58. @miciek Pure Concepts As Names distance_between_abscissae = first_abscissa - second_abscissa

    distance_between_ordinates = first_ordinate - second_ordinate cartesian_distance = square_root( distance_between_abscissae * distance_between_abscissae + distance_between_ordinates * distance_between_ordinates) Lawrie, Morrell - “Identifier length and limited programmer memory”
  59. @miciek Concept Can Be An Abbreviation distance_between_abscissae = first_abscissa -

    second_abscissa distance_between_ordinates = first_ordinate - second_ordinate cartesian_distance = square_root( distance_between_abscissae * distance_between_abscissae + distance_between_ordinates * distance_between_ordinates) dx = x1 - x2 dy = y1 - y2 dist = sqrt(dx * dx + dy * dy) Concepts (C) dx dy dist x1 x2 y1 y2 Lawrie, Morrell - “Identifier length and limited programmer memory”
  60. @miciek Being A Good Naming Craftsman one name per concept

    no homonyms no synonyms well defined abbreviations
  61. @miciek Being A Good Naming Craftsman one name per concept

    no homonyms no synonyms well defined abbreviations currently impossible!
  62. @miciek Being A Good Decent Naming Craftsman don’t pick on

    someone else’s names find & analyse existing names
  63. @miciek Agenda Intuition & Illusions Example: Names Example: Backlog DETOX

    before DETOX after
  64. @miciek Backlog = To-Do List “ ...list of features or

    technical tasks which the team maintains and which, at a given moment, are known to be necessary and sufficient to complete a project or a release. - Agile Alliance https://www.atlassian.com/agile/backlogs
  65. @miciek Dev’s To Do Dev’s To Do Stakeholders’ To-Do Dev’s

    To Do User’s To Do PO’s To Do Team’s To Do Backlog
  66. @miciek Brain Dump Call Mom Jim’s flowers Take out trash

    Do bank papers Buy lightbulbs Fix bug in X Fix flaky test Add Feature Z Refactor Y’s API Better names in X
  67. @miciek iDoneThis case http://blog.idonethis.com/how-to-master-the-art-of-to-do-lists/ Done List 160,000 users done to-do

    reported dones
  68. @miciek 85% dones were not to-do items Human vs Human’s

    Plan 41% to-do items never completed http://blog.idonethis.com/how-to-master-the-art-of-to-do-lists/ 78% to-do items done within a day We suck at planning and there is no hope...
  69. @miciek Ocado Backlogs Project Total Items Never Done Never Done

    % Pick Station 1337 637 47% Phoenix Core 1192 553 46% Decant 1013 437 43% Phoenix Outbound 1725 618 35% OSP RMS 379 105 27% Hawk 1763 395 22% Data gathered 6.02.2017
  70. @miciek Why Do We Do That? 20-50% backlog items never

    completed someone created them someone discussed them someone analysed them someone groomed them someone prioritised them someone deleted them
  71. @miciek Zeigarnik Effect https://pl.pinterest.com/pin/59250551327511553/

  72. @miciek Zeigarnik Intrusions Experiment Masicampo, Baumeister - “Consider It Done!

    Plan Making Can Eliminate the Cognitive Effects of Unfulfilled Goals” Group #1 “Unfulfilled” Group #2 “Plan” Group #3 “Control” 2 important future tasks 2 important past tasks - make when, why, how plans - read 3,200 words answer questions about the text
  73. @miciek Zeigarnik Intrusions Masicampo, Baumeister - “Consider It Done! Plan

    Making Can Eliminate the Cognitive Effects of Unfulfilled Goals” Group #1 “Unfulfilled” Group #2 “Plan” Group #3 “Control” ability to focus (1-7) 4.61 5.56 5.29 mind wanderings 65% 33% 50% reading comprehension 6.13 6.94 6.93
  74. @miciek Masicampo, Baumeister - “Consider It Done! Plan Making Can

    Eliminate the Cognitive Effects of Unfulfilled Goals” “Participants who reflected on two important but unfinished tasks were distracted…” “...forming a plan can eliminate cognitive activity from unfulfilled goal…” PLAN = how, when, and why to complete the goal
  75. @miciek Does It Work For Multiple Goals? NO! “...specific planning

    is less effective for multiple goals versus a single goal..”
  76. @miciek Being A Backlog-aware Craftsman don’t add things to backlog

    add only if you have a detailed plan add only if you’ll do it very soon
  77. @miciek John Had A Problem stay until names are fixed

    ask the team to finish merge change add “fix names” to backlog leave and continue when you’re back
  78. @miciek John Was Under Influence of Illusions

  79. @miciek Developer DETOX on Doesn’t say ▪ “This is a

    good practice…” ▪ “This is an antipattern…” ▪ “Uncle Bob said that…” ▪ “Everybody knows that…” ▪ “This is prerequisite for having a clean code...” ▪ “This is not advised...”
  80. @miciek Developer DETOX on Says ▪ “Let me check the

    research about…” ▪ “Let me do an experiment…” ▪ “Here’s data that supports my claim…” And... ▪ “I am sorry, I used my intuition here…”
  81. @miciek John Did Some Research! don’t pick on someone else’s

    names find & analyse existing names
  82. @miciek John Did Some Research! don’t add things to backlog

  83. @miciek John Did Some Research! ▪ read some papers ▪

    did some experiments ▪ drew conclusions
  84. @miciek ▪ “Folklore and science of naming practices” http://michalplachta.com/2017/01/22/folklore-and-science-of-naming-practices/ ▪

    “Quantifying Identifier Quality: An Analysis of Trends” Lawrie, Feild, Binkley http://www.cs.loyola.edu/~lawrie/papers/lawrieJese07.pdf ▪ “Concise and Consistent Naming” Deißenböck & Pizka http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.70.618&rank=1 ▪ “Clean Code: A Handbook of Agile Software Craftsmanship” Robert C. Martin ▪ “Maintaining Mental Models: A Study of Developer Work Habits” LaToza, Venolia, DeLine http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.111.2317&rank=1 ▪ “Identifier length and limited programmer memory” Binkley, Lawrie, Maex, Morrell ▪ “The effects of comments and identifier names on program comprehensibility: An experimental investigation” Takang, Grubb, Macredie ▪ “Effective Identifier Names for Comprehension and Memory” Lawrie, Morrell, Feild, Binkley References - Naming Research
  85. @miciek ▪ “What a To-Do: Studies of Task Management Towards

    the Design of a Personal Task List Manager” Bellotti, Dalal, Good, Flynn, Bobrow. Ducheneaut ▪ “How to Master the Art of To-Do Lists by Understanding Why They Fail” http://blog.idonethis.com/how-to-master-the-art-of-to-do-lists/ ▪ “Consider It Done! Plan Making Can Eliminate the Cognitive Effects of Unfulfilled Goals” Masicampo, Baumeister ▪ “Too Much of a Good Thing: The Benefits of Implementation Intentions Depend on the Number of Goals” Dalton, Spiller ▪ “To-Do Lists Don’t Work” https://hbr.org/2012/01/to-do-lists-dont-work ▪ “The Scrum Backlog is where Features go to die” https://medium.com/product-love/the-scrum-backlog-is-where-features-go-to-die- b1336ff707aa References - Backlog Research
  86. @miciek ▪ “Velocipedia” https://www.dezeen.com/2016/06/19/velocipedia-project-hopeless-bicycle-dra wings-life-digital-renders-gianluca-gimini/ ▪ “The Invisible Gorilla: How

    Our Intuitions Deceive Us” Chabris, Simons References - Intuition Research
  87. @miciek Thanks! Developer DETOX on ANY QUESTIONS? Michał Płachta www.michalplachta.com

  88. @miciek ~FIN~