Slide 1

Slide 1 text

Trisha Gee Lead Developer Advocate, Gradle @trisha_gee trishagee.com Reading Code is Harder Than Writing It

Slide 2

Slide 2 text

● Lead Developer Advocate ● Java Champion & JetBrains Community Contributor ● 20+ years development experience ● Author Trisha Gee

Slide 3

Slide 3 text

Room on the Broom Julia Donaldson & Axel Scheffler

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

READING CODE

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Why do we read code?

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

“Every programmer occasionally, when nobody’s home, turns off the lights, pours a glass of scotch, puts on some light German electronica, and opens up a file on their computer. They read over the lines, and weep at their beauty….” https://www.stilldrinking.org/programming-sucks

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

What are the problems?

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

“This file is Good Code. It has sensible and consistent names for functions and variables. It’s concise. It doesn’t do anything obviously stupid…. It reads like poetry written by someone over thirty.” https://www.stilldrinking.org/programming-sucks

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

“Real stupidity beats artificial intelligence every time.” Hogfather Terry Pratchett

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Tips

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

“After enough exposure with feedback, your brain began detecting patterns and underlying structures, without your conscious awareness. With more exposure, your brain finetuned its perception and eventually figured out what really mattered. Your brain was making finer distinctions and sorting signal from noise even if you couldn’t explain how.” Badass: Making Users Awesome Kathy Sierra

Slide 47

Slide 47 text

Where to practice • Your codebase • Open source • Libraries you’re using • Coding katas

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Don’t Judge • Explore • Make notes • Questions • Discoveries • Assumptions • Draw diagrams • Don’t change the code

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Twelfth Night William Shakespeare

Slide 52

Slide 52 text

Structure • Services • Modules • Packages • Layers • Patterns • Naming • Relationships • Responsibilities • Data flow • Build order

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

“If music be the food of love, play on, Give me excess of it; that surfeiting, The appetite may sicken, and so die.” Twelfth Night William Shakespeare

Slide 56

Slide 56 text

Whylom, as olde stories tellen us, Ther was a duk that highte Theseus; Of Athenes he was lord and governour, And in his tyme swich a conquerour, That gretter was ther noon under the sonne. The Canterbury Tales, and Other Poems Geoffrey Chaucer (1387–1400)

Slide 57

Slide 57 text

Cantar de mio Cid Composed sometime between 1140 and 1207

Slide 58

Slide 58 text

Consider • Language • Libraries • Age • Patterns • Standards • Code shape • False friends

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

IDE Navigation https://youtu.be/1UHsJyCq1SU

Slide 65

Slide 65 text

Open it in your IDE

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

“If you don't think about the underlying mechanics of the simulation—even if that thinking happens in a semiconscious way—you won't last very long in the game. You have to probe to progress.” Everything Bad is Good for You: How Popular Culture is Making Us Smarter Steven Johnson

Slide 68

Slide 68 text

Run code to understand it • Code analysis tools • Debugger • Watches • Evaluate expression

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

“The game scholar James Paul Gee breaks probing down into a four-part process, which he calls the ‘probe, hypothesize, reprobe, rethink’ cycle” Everything Bad is Good for You: How Popular Culture is Making Us Smarter Steven Johnson

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

“It may, or may not, have helped Anathema get a clear view of things if she’d been allowed to spot the very obvious reason why she couldn’t see Adam’s aura. It was for the same reason that people in Trafalgar Square can’t see England.” Good Omens Neil Gaiman & Terry Pratchett

Slide 74

Slide 74 text

Tips 1. Practice 2. Reading is not reviewing 3. Code bases have a shape 4. Code bases have a dialect 5. Code is not linear 6. Code is meant to be run 7. If you must write, write tests 8. If you must change it, throw it away 9. Not all knowledge can be codified

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

“I’m grizzly and grumpy and grouchy and grumbly I’ve not been called lovely before!” The Giant of Jum Elli Woollard & Benji Davies

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

Conclusion

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

Donald Knuth – Literate Programming (1984) Code should be written to be read and understood, not just executed. Steve McConnell – Code Complete (1993) Developers spend more time reading code than writing it. Raymond Chen – Microsoft Developer Blog (2007) "Code is read much more often than it is written, so plan accordingly." Robert C. Martin (Uncle Bob) – Clean Code (2008) “Indeed, the ratio of time spent reading versus writing is well over 10 to 1.” Daniel Roy Greenfeld “Code is read more than it is written.” ChatGPT

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

“My fingers,” said Elizabeth, “do not move over this instrument in the masterly manner which I see so many women’s do. They have not the same force or rapidity, and do not produce the same expression. But then I have always supposed it to be my own fault — because I will not take the trouble of practising.” Pride & Prejudice Jane Austen

Slide 90

Slide 90 text

http://bit.ly/reading_code