Slide 1

Slide 1 text

Maintaining Software Correctness Dan Lew source: https://www. fl ickr.com/photos/eliasroviello/43464129670

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

RxLifecycle observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .bindToLifecycle() // Forget this and leak memory! .subscribe()

Slide 4

Slide 4 text

RxLifecycle observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .bindToLifecycle() // Forget this and leak memory! .subscribe()

Slide 5

Slide 5 text

Correctness Dilemma • Stu ff is easy to create, hard to maintain! • Avoiding RxJava memory leaks • Maintaining code style • Contributing to an OSS codebase • Consistently releasing builds

Slide 6

Slide 6 text

design for human fa libility l

Slide 7

Slide 7 text

Two Big Ideas • Human processes can become software processes • The less freedom you give, the more likely you’ll maintain correctness

Slide 8

Slide 8 text

Correctness Strategies source: https://pixabay.com/photos/target-aim-arrows-bow-quiver-459833/

Slide 9

Slide 9 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 10

Slide 10 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 11

Slide 11 text

Institutional Knowledge • Stu ff in your head • The good • Everything starts here • Cheap • Flexible • Explains & summarizes • Describes human problems

Slide 12

Slide 12 text

Institutional Knowledge • The bad • Misremembered, forgotten, or leaves • Laborious to share • Hard to communicate • No reminders

Slide 13

Slide 13 text

Institutional Knowledge

Slide 14

Slide 14 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 15

Slide 15 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 16

Slide 16 text

Documentation • Institutional knowledge, written down • Harder to forget • Easier to broadcast • Can use visuals • Checklists for complex processes

Slide 17

Slide 17 text

Documentation • The bad… • Badly written or misunderstood • Often poorly maintained • Hard to fi nd or just ignored • No reminders

Slide 18

Slide 18 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 19

Slide 19 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 20

Slide 20 text

Affordances “The quality or property of an object that de fi nes its possible uses or makes clear how it can or should be used”

Slide 21

Slide 21 text

Affordances https://commons.wikimedia.org/wiki/File:Set_of_Crash_Bar_Doors.jpg VS https://www. fl ickr.com/photos/79157069@N03/40530223463

Slide 22

Slide 22 text

Affordances • A ff ordant APIs invisibly guide people toward correctness • Una ff ordant APIs make exceptions uncomfortable • Existing code creates peer pressure • A ff ordances cannot restrict, only guide

Slide 23

Slide 23 text

Affordances

Slide 24

Slide 24 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 25

Slide 25 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 26

Slide 26 text

Software Checks • Code that checks itself • Timing matters! • Fast feedback is better

Slide 27

Slide 27 text

Runtime Checks • Checks while running your code • Can check almost anything… • …But, users might be your testers, oops! • Use as last resort

Slide 28

Slide 28 text

Manual Checks • Unit/integration/etc. tests • Very wide range of testable logic! • Must foster culture of testing • Architecting for tests • Taking time to write tests • Verifying test correctness

Slide 29

Slide 29 text

Automatic Checks • Manual tests that start themselves

Slide 30

Slide 30 text

Compiler Checks • Compiler enforces its own rules • Can go beyond the compiler… • Code style • Lint • Code coverage • Manual checks

Slide 31

Slide 31 text

Design Checks • Checks editor makes before compilation • Instant feedback • Still not limited to compiler • IDEs can support code style, lint, etc.

Slide 32

Slide 32 text

Software Checks • Faster feedback is better • Faster feedback is more constrained

Slide 33

Slide 33 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 34

Slide 34 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 35

Slide 35 text

Constraints • Make it impossible to do wrong • Enums vs. stringly-typing • Stateless functions vs. stateful classes • Pull requests vs. merging to main • Bonus: limits headspace & test cases, too!

Slide 36

Slide 36 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 37

Slide 37 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 38

Slide 38 text

Automation • No humans are involved • Code generation • Continuous integration • Automatic deployments • Write once, run over and over • High e ff ort to write & maintain automation

Slide 39

Slide 39 text

Correctness Strategies • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 40

Slide 40 text

Analysis source: https://pxhere.com/en/photo/1450669

Slide 41

Slide 41 text

Analysis • Consider correctness while solving problems • Mix multiple strategies together

Slide 42

Slide 42 text

Analysis • Rigidity gets you correctness… • …but it costs you in fl exibility • Balance fl exibility vs. correctness

Slide 43

Slide 43 text

Analysis • You can implement correctness badly • Flakey software checks • Annoying contribution process • Di ffi cult automation maintenance • No escape hatch for new features • Make sure costs are worth it

Slide 44

Slide 44 text

Analysis • Need team buy-in • Agreement makes correctness easier to implement • Disagreement leads to toxicity • Start with experiments, then make your case

Slide 45

Slide 45 text

source: https://www.picpedia.org/suspension- fi le/e/examples.html

Slide 46

Slide 46 text

Code Style • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 47

Slide 47 text

Contributing to an OSS project • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 48

Slide 48 text

Cleaning Streams • Institutional Knowledge • Documentation • A ff ordances • Software Checks • Constraints • Automation Flexible Rigid

Slide 49

Slide 49 text

@danlew42