Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

Michał Płachta

February 25, 2017
Tweet

More Decks by Michał Płachta

Other Decks in Programming

Transcript

  1. @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
  2. @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
  3. @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!
  4. @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%]
  5. @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
  6. @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
  7. @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
  8. @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
  9. @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/
  10. @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?
  11. @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?
  12. @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?
  13. @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.
  14. @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.
  15. @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!
  16. @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
  17. @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...”
  18. @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
  19. @miciek “ There are only two hard things in Computer

    Science: cache invalidation and naming things. - Phil Karlton
  20. @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
  21. @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%
  22. @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”
  23. @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”
  24. @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”
  25. @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?
  26. @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.
  27. @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”
  28. @miciek n1 Identifier Names (N) Concepts (C) book to book

    a book number accountNumber an account number a phone number Homonyms & Synonyms
  29. @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
  30. @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
  31. @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”
  32. @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”
  33. @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”
  34. @miciek Being A Good Naming Craftsman one name per concept

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

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

    someone else’s names find & analyse existing names
  37. @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
  38. @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
  39. @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
  40. @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...
  41. @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
  42. @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
  43. @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
  44. @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
  45. @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
  46. @miciek Does It Work For Multiple Goals? NO! “...specific planning

    is less effective for multiple goals versus a single goal..”
  47. @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
  48. @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
  49. @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...”
  50. @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…”
  51. @miciek John Did Some Research! ▪ read some papers ▪

    did some experiments ▪ drew conclusions
  52. @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
  53. @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