Video: Unconditional Code - Michael Feathers

November 28th, 2020

Unconditional Code - Michael Feathers

(https://www.youtube.com/watch?v=AnZ0uTOerUI)

 

no description for image available

 

no description for image available

 

Null Object Pattern

no description for image available

something bad has happened, but we'll act like it didn't

others: NaN, [], null, special case

 

no description for image available

that error is part of our domain

 

same in functional

no description for image available

 

no description for image available

error has moved to the place where the error occurred

no description for image available

when successful, do this

 

no description for image available

 

no description for image available

 

 

---

 

Example

no description for image available

count # groups of '1' (blue here)

 

no description for image available

"edgy code", it has a lot of edge cases

 

no description for image available

add 0 at front, removes one edge

no description for image available

we eliminated an edge, by extending the domain

 

 

example

no description for image available

 

no description for image available

 

no description for image available

 

no description for image available

makes it more general, can now work with multiple files

generalizing the problem a bit, so that things that can occur can be okay

 

no description for image available

 

no description for image available

extend the range of input

so some things are not an error

 

not here:

no description for image available

 

we do here:

no description for image available

 

make a bet: when you extend the domain, people will understand that

 

no description for image available

 

no description for image available

 

 

no description for image available

 

2 parts of the program

1) checking

2) do stuff

 

 

no description for image available

area where there is no need of error checking

 

option monad in haskell, mimicked in haskell)

no description for image available

output =

- cumulative error message

- or

- actual output

=> mixed feeling

 

no description for image available

exceptions should be like a time machine

(like transactions)

 

intention can succeed or fail

 

example: shuffle

no description for image available

 

5 why when designing

no description for image available

 

error handling: distance between detecting problem and what you go and do about it

if I can't read a config, can I use a default config + notify?

 

always question errors

can't eliminate entirely

but can we restructure the system so as to remove this error?

 

 

tended systems vs untended systems

no description for image available

 

no description for image available

 

no description for image available

 

no description for image available

 

supervisor trees = mimic the human

 

cost choice

safety choice

 

no description for image available

 

no description for image available

 

no description for image available

 

counter-intuitive

no description for image available

care happens when there is hazard

 

vs:

rust - prevent things from happening

erlang - react to when they happen

 

no description for image available