Slide 1

Slide 1 text

Daniel van Berzon @ocastahq ocasta.com @dvberzon vanberzon.com

Slide 2

Slide 2 text

Help us discover what makes code readable!

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

What they have in common are rules Rules Broken

Slide 6

Slide 6 text

Grammar rules Prescriptive Descriptive

Slide 7

Slide 7 text

Prescriptive Arbitrary grammar rule that prescribes the way people should speak "Never end a sentence with a preposition!"

Slide 8

Slide 8 text

What is he on about?

Slide 9

Slide 9 text

What is he on about? preposition

Slide 10

Slide 10 text

What is he on about? preposition About what is he on?

Slide 11

Slide 11 text

What is he on about? preposition About what is he on? On about what is he? !

Slide 12

Slide 12 text

"Never end a sentence with a preposition!" Joshua Poole (1646) John Dryden (1672) Prescriptive What is he on about?

Slide 13

Slide 13 text

Descriptive Evidence-based Grammar rule that describes the way people speak naturally. "English word order is: Subject - Verb - Object"

Slide 14

Slide 14 text

Penny eats pizza Penny pizza eats Eats penny pizza Eats pizza penny Pizza penny eats Pizza eats penny

Slide 15

Slide 15 text

Penny eats pizza Penny pizza eats Eats penny pizza Eats pizza penny Pizza penny eats Pizza eats penny

Slide 16

Slide 16 text

Penny eats pizza Subject - Verb - Object Descriptive Penny eats Pizza

Slide 17

Slide 17 text

Readable Code Rules

Slide 18

Slide 18 text

Airbnb JavaScript Style Guide: // bad function sayHi(name) { return 'How are you, ' + name + '?'; } // good function sayHi(name) { return `How are you, ${name}?`; } Template strings give you a readable, concise syntax ... “ ” Often mentions readability

Slide 19

Slide 19 text

Prescriptive • Arbitrary • Opinions as facts • No evidence

Slide 20

Slide 20 text

Descriptive rules For readable code?

Slide 21

Slide 21 text

Online experiment to find descriptive rules for code readability Measures readability of coding constructs Showing code snippets to developers Measuring how easily they read them

Slide 22

Slide 22 text

What do we measure? Can developer predict output of code? Time takes them to understand the code

Slide 23

Slide 23 text

Comments // foo Are /*comments*/ readable?

Slide 24

Slide 24 text

Comments // foo Are /*comments*/ readable?

Slide 25

Slide 25 text

Comments // foo Are /*comments*/ readable? 75% 50% } }

Slide 26

Slide 26 text

Experiment is live Measuring 11 constructs > 500 participants Need more participants to get better results Comments Naming Pure functions Abstraction Boolean algebra Ternary operators Chaining methods If statements Inline functions Early return Operator precedence

Slide 27

Slide 27 text

• Developer • JavaScript • 10 minutes howreadable.com You can help!

Slide 28

Slide 28 text

Help us discover what makes code readable! howreadable.com

Slide 29

Slide 29 text

Daniel van Berzon @ocastahq ocasta.com @dvberzon vanberzon.com Thank you! howreadable.com