Poka-Yoke is Not a Joke (2010)
hbr.org
hbr.org
On of the well known Poka-Yoke strategies are cables that can not be plugged to the wrong port since there is a different one for everything. Kind of relates well to function signatures that make sure only the right type of data comes in.
You can easily design type system + compiler, which will have destructive "attitude".
It's no different from human interactions and how being "right" is not always "being constructive".
Best type systems have low mental overhead, can be selectively applied (to benefit when it's profitable, and to avoid costs where it's too costly), are humble, and are good companions by helping developer learn the domain space.
E.g. 1 there are good blog posts describing how you can write Haskell code by just asking Haskell compiler what type is needed to fit with the rest of your code. Step by step you fill in the blanks.
E.g. 2 there are good videos from Clojure about how you can follow types to implement a new idea.
Counter example: Neither 1) nor 2) is possible in C, and yet you pay hefty price mandated by C type system.
All 3 type systems have their own trade offs. Picking one that is most aligned with goals of your project does have impact :)
"parse, don't validate" (https://news.ycombinator.com/item?id=21476261) too. An API that prevents you from doing the wrong thing too. Banning a dangerous function too (that's linting, I suppose).
Tools were stored in a special toolbox. The tools each had a slot to be stored in (the slots were foam, cut in the silhouette of the tool, so only that tool could be stored there). Each slot had a sensor to tell if the tool was there. You had to scan your ID to open the box. A computer system logged which tools you took, and you could not punch out your time card until all your tools were returned.
The system was complex and costly to build, but less costly than a single mistake like the one that inspired it.
https://www.seattletimes.com/business/boeing-aerospace/boein...
Preventing surgical instruments is easier the more expensive the tool is. Anything over $5 can easily get a RFID tag and you can simply scan the patent then the work area to get accountability. The hard part is with gauze and other cheap items that can’t easily be tagged, and will be going inside the body, so they have very high biocompatibility requirements (eg: inks in spectrum transparent to blood might be too toxic to use).
A key principle is making different things look different. In a mechanical assembly, often you see very different pins and fasteners doing similar jobs - but what may seem an oddity on the part of the designer is a godsend when assembling. I'm sure we've all puzzled over putting together household objects where you have several slightly-different lengths of the same screw. In software, consistency is incredibly important, so that users can expect behaviours and discover features, but there's still a case for making different things visibly different.
if ( 0 == x )
makes the mistake of accidentally writing assignment there impossible (0 = x would generate an error). However, my belief is that we should both demand and expect from the tools to have the "reasonable defaults" i.e. even if the if ( x = 0 )
is a valid code, the "reasonable default" of the compiler has to be at least a warning. But who says that the environment where the compiler is used has "reasonable defaults" itself? I've worked in some environment where it was really expected from every participant to "ignore the warnings" produced during the build process. Which just shows how hard it is in some environment to even start a culture of "making the errors less possible": "don't waste the time, we have other methods to detect the problems, just do how it is done here" etc.Viewed from the higher level, it is always about human weaknesses, still, it's always harder to address such weaknesses present on the higher levels.
- I leave my backpack against the door to make sure I don't leave the house without it.
- I put coloured tape around the 10 mm spanner, and the 10 mm socket. The 12 mm socket is 2 sockets to the right.
- Every tool has a place. If a slot is empty, a tool is missing.
- When I disassemble something, I place all the screws down in order. When I put everything back together, I should always need the rightmost screw.
- I always do mise en place before cooking. If an ingredient is missing, I'll know before I start cooking.
I also try to implement them in the workplace. Errors can happen, but they shouldn't happen twice.
I've been incorporating ReadMe.md files in most projects and folders, as well as self documenting Makefiles, with their default target set to help so that it displays something informative about what it will build.
Most of the times I try to include some sort of testing, or alternatively generate index files about the dependencies needed to build.
This has helped me remember the essential parts faster when I revisit projects that haven't been in my mind lately, thus I avoid mis-typing commands and 'forgetting' information.