Coding Fast and Slow: Applying Kahneman’s Insights to Improve Development Practices and Efficiency

A presentation at Open Conf 2023 in November 2023 in Athens, Greece by Baruch Sadogursky

Slide 1

Slide 1

Coding Fast and Slow

Slide 2

Slide 2

Slide 3

Slide 3

Baruch Sadogursky - @jbaru ch × Developer Productivity Advocate × Gradle Inc × Development -> DevOps -> #DPE

Slide 4

Slide 4

shownotes × × × × speaking.jbaru.ch Slides Video All the links!

Slide 5

Slide 5

Slide 6

Slide 6

A bat and a ball cost $1.10 in total. The bat costs $1 more than the ball. How much does the ball cost?

Slide 7

Slide 7

How much does the ball cost? C10 + $1.10 = $1.20 C5 + $1.5 = $1.10

Slide 8

Slide 8

Two systems x x x x x Fast Intuitive Automatic Emotional Cheap and eager x x x x x Slow Analytical Controlled Logical Expensive and lazy

Slide 9

Slide 9

Remember the following numb × × × × × ers: 34687 56820 76378 90824 11247 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

Slide 14

Slide 14

Slide 15

Slide 15

You have “mental fuel”

Slide 16

Slide 16

Slide 17

Slide 17

Slide 18

Slide 18

Slide 19

Slide 19

Attention and Capacity Limits in Perception: A Cellular Metabolism Account × × × × BNIRS and oxCCO Cellular Metabolism as Mental Fuel Finite Energy Supply High Load Mode vs Low Load Mode 19

Slide 20

Slide 20

Which system do we use for co d ing? x x x x x Fast Intuitive Automatic Emotional Cheap and Eager x x x x x Slow Analytical Controlled Logical Expensive and Lazy

Slide 21

Slide 21

Slide 22

Slide 22

Slide 23

Slide 23

effortless

Slide 24

Slide 24

Slide 25

Slide 25

Slide 26

Slide 26

26

Slide 27

Slide 27

def calculate_discount(price, discount): # Calculate the final price after discount final_price = price - (price * discount / 100) print(f”The final price after a {discount}% discount is: {final_price}”) return final_price # Example usage calculate_discount(100, 10)

Slide 28

Slide 28

How Many Triangles?

Slide 29

Slide 29

def calculate_tax(amount, tax_rate): # Calculate the total amount after tax total_amount = amount + (amount * tax_rate) print(f”The total amount with tax is: {total_amount}”) return total_amount # Example usage calculate_tax(100, 5)

Slide 30

Slide 30

The problem: × You deplete your fuel by contextswitching × You’re not in the flow because of context-switching × Loose-loose: you need more fuel needed, but you have less fuel

Slide 31

Slide 31

Slide 32

Slide 32

When we are tired, we produce worse code × “Developers are cutting corners on quality when fatigued.” (duh)

Slide 33

Slide 33

Slide 34

Slide 34

But We don’t know when to qu x x x it Parole Judges issued fewer paroles when tired and/or hungry Granting parole requires System 2 The Judges didn’t realize they had switched to System 1

Slide 35

Slide 35

Real-life outcome: you run on system one x x x x x Fast Intuitive Automatic Emotional Cheap and Eager x x x x x Slow Analytical Controlled Logical Expensive and Lazy

Slide 36

Slide 36

Slide 37

Slide 37

Which sucks less? Bad code “OK” code

Slide 38

Slide 38

The problem of “ok code” It looks “OK” to us System 1 It looks “OK” to PR review System 1 It looks “OK” to pipelines System 1

Slide 39

Slide 39

Next thing you know: You have an “ok” product

Slide 40

Slide 40

Invest in The goal: Running on System 2 all-day

Slide 41

Slide 41

Time Management Strategies × Time Blocking × Pomodoro Technique × Task Batching

Slide 42

Slide 42

Mindfulness and Cognitive Pra ctices × Mindfulness and Meditation × Reflective Practices × Single-tasking

Slide 43

Slide 43

Workspace and Interruption M anagement × Workspace Organization × Notification Management × Prioritization Techniques

Slide 44

Slide 44

Physical and Mental Well-bein g × Physical Exercise × Breaks and Downtime

Slide 45

Slide 45

And… Developer productivity Engineering!

Slide 46

Slide 46

Developer Productivity Enginee Foster Faster Feedback Collaborate through Effective Tooling Eliminate Toil for Developers Dedicated Organizational Mindset ring Embrace Rigorous Observability for Proactive Improvement Prioritize Automation and Eliminate Bottlenecks Outcomes Over Output

Slide 47

Slide 47

“Faster foster feedback” saves Speeding up local build minimizes context switch Less context switch saves mental fuel mental fuel Run on System 2 all-day

Slide 48

Slide 48

How can we engineer less con tex × × × × × × t switches? Measure local build times! Caching, local and remote Parallel testing, local and remote Predictive test selection Fight evil flaky tests! Watch your build like a hawk for degradations

Slide 49

Slide 49

What you can do today (for fr ee × × × × × ) Parallel local Local caching Remote caching* Build Scans Win Prizes (a.k.a. speed challenge)

Slide 50

Slide 50

What your company should pa y for × Top development hardware × Develocity (or similar)

Slide 51

Slide 51

Learn more and try it today! × × × × Take the Gradle/Maven Speed Challenge Be DPE Agent of Change! Read the DPE Handbook Watch the DPE Summit videos (published soon!) x speaking.jbaru.ch

Slide 52

Slide 52