Strategic Code Deletion Michael Feathers R7K Research & - - PowerPoint PPT Presentation

strategic code deletion
SMART_READER_LITE
LIVE PREVIEW

Strategic Code Deletion Michael Feathers R7K Research & - - PowerPoint PPT Presentation

Strategic Code Deletion Michael Feathers R7K Research & Conveyance (everyone wants to delete code) When Can We Delete Code? Varieties of Useless Code And another one.. Low Value code No wikipedia entry (yet) :-) Coverage gprof


slide-1
SLIDE 1

Strategic Code Deletion

Michael Feathers

R7K Research & Conveyance

slide-2
SLIDE 2
slide-3
SLIDE 3

(everyone wants to delete code)

slide-4
SLIDE 4

When Can We Delete Code?

slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7

Varieties of Useless Code

slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10

And another one..

Low Value code

No wikipedia entry (yet) :-)

slide-11
SLIDE 11

Coverage

slide-12
SLIDE 12

gprof

slide-13
SLIDE 13

https://nylas.com/blog/performance/

slide-14
SLIDE 14

Mutation Testing

slide-15
SLIDE 15

Feature Probe

slide-16
SLIDE 16

scythe_probe(“marker”);

Feature Probe

slide-17
SLIDE 17

scythe_probe(“marker”);

Feature Probe

  • Record marker
  • Periodically check for absence of marker
slide-18
SLIDE 18

Feature Probe

slide-19
SLIDE 19

Pricer Scan Devices Promotions Reconciliation Inventory Edge Client

  • Accept gift card
  • Split charge (2 customers)
  • Select home delivery
  • Produce/Meat by weight
  • Daily specials
  • Weekly specials
  • Restock perishable schedule
  • Record invalid scans
  • Change till procedure
  • Cashier login
  • Register reconcile
slide-20
SLIDE 20

The Cost Case

slide-21
SLIDE 21

Unreachable Code Dead Code Low Value Code

Compiler Errors / Warnings Mutation Testing Feature Probes / Stack Sampling / Coverage Delete on Detect Delete on Detect Strategize

slide-22
SLIDE 22
  • Delete Unreachable and Dead Code on Detection
  • Disable Low

Value Code at entry points

  • Verify in sample

Strategy

slide-23
SLIDE 23

Human in the Loop for Internal Pruning

slide-24
SLIDE 24

Systematic Rewrite

slide-25
SLIDE 25

Most rewrites are motivated by technology or architectural change

slide-26
SLIDE 26

Most rewrites are motivated by technology or architectural change

“Cleaning rewrites” should be focused and selective

slide-27
SLIDE 27

(from Jez Humble)

slide-28
SLIDE 28

Key Actions for Rewrite

  • Can you find all inputs and outputs?
  • Are you reducing conditionality?
  • Are you scoped for Characterization

Testing?

  • Can you run redundant?
slide-29
SLIDE 29

Searching for Pinch Points

slide-30
SLIDE 30

Characterization Testing

Tests you write to describe the current behavior of your system

slide-31
SLIDE 31

Characterization Testing

Tests you write to describe the current behavior of your system

How is this different from other testing?

slide-32
SLIDE 32
slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35
slide-36
SLIDE 36
slide-37
SLIDE 37
slide-38
SLIDE 38
slide-39
SLIDE 39
slide-40
SLIDE 40
slide-41
SLIDE 41
slide-42
SLIDE 42
slide-43
SLIDE 43

Is this a bug?

slide-44
SLIDE 44

Simple Case Heuristics

slide-45
SLIDE 45
  • Start with “x”
  • Use expressive (long) names
  • Rename to tell a story
  • Make the call on bugs
  • Be curious!

Simple Case Heuristics

slide-46
SLIDE 46
  • Start with “x”
  • Use expressive (long) names
  • Rename to tell a story
  • Make the call on bugs
  • Be curious!

Simple Case Heuristics

slide-47
SLIDE 47
  • Start with “x”
  • Use expressive (long) names
  • Rename to tell a story
  • Make the call on bugs
  • Be curious!

Simple Case Heuristics

slide-48
SLIDE 48
  • Start with “x”
  • Use expressive (long) names
  • Rename to tell a story
  • Make the call on bugs
  • Be curious!

Simple Case Heuristics

slide-49
SLIDE 49
  • Start with “x”
  • Use expressive (long) names
  • Rename to tell a story
  • Make the call on bugs
  • Be curious!

Simple Case Heuristics

slide-50
SLIDE 50

What was our goal?

slide-51
SLIDE 51
slide-52
SLIDE 52
slide-53
SLIDE 53

✔ balance ✔ gallons ✘ RESIDENTIAL_MIN ✘ RESIDENTIAL_BASE

slide-54
SLIDE 54

Tooling Varies

slide-55
SLIDE 55
slide-56
SLIDE 56
slide-57
SLIDE 57
slide-58
SLIDE 58

Reducing Conditionality

slide-59
SLIDE 59

Apache

slide-60
SLIDE 60

Microsoft IIS

slide-61
SLIDE 61

if (…) { … }

slide-62
SLIDE 62
slide-63
SLIDE 63
slide-64
SLIDE 64

Edge-Free Programming

slide-65
SLIDE 65
slide-66
SLIDE 66

Redund Until Replace

slide-67
SLIDE 67

Redund Until Replace

When you have a pure section of code that is a replacement, run it in parallel and log if there are differences

slide-68
SLIDE 68

Conclusion

slide-69
SLIDE 69

Pricer Scan Devices Promotions Reconciliation Inventory Edge Client

  • Accept gift card
  • Split charge (2 customers)
  • Select home delivery
  • Produce/Meat by weight
  • Daily specials
  • Weekly specials
  • Restock perishable schedule
  • Record invalid scans
  • Change till procedure
  • Cashier login
  • Register reconcile
slide-70
SLIDE 70