error-prevention - Concepts
Explore concepts tagged with "error-prevention"
Total concepts: 14
Concepts
- Parse, Don't Validate - Turn untrusted input into precise, typed data at the edge of your system, instead of checking it and passing the same loose data along.
- Pit of Success - Build systems so that the easiest path is also the right one: people fall into good results by default, and they have to work hard to get things wrong.
- Footgun - A feature, tool or API that makes it easy to shoot yourself in the foot: the obvious use works most of the time, then does something harmful that nobody notices right away.
- Stringly Typed - Code that uses plain strings for values that deserve a real type, such as states, keys, dates or identifiers, so the compiler can't catch mistakes that a proper type would prevent.
- Null References - The practice of letting any reference point to "nothing", which Tony Hoare, who introduced it in 1965, later called his "billion-dollar mistake".
- Total Functions - A total function returns a valid result for every possible input of its type; a partial function only works for some inputs and crashes, throws or misbehaves on the others.
- Hard to Misuse - Make interfaces easy to use correctly and hard to use incorrectly, so the design prevents mistakes instead of relying on the documentation.
- Typestate Pattern - A design technique that encodes an object's current state in its type, so calling an operation in the wrong state becomes a compile-time error instead of a runtime bug.
- Poka-Yoke - A mistake-proofing mechanism built into a process or design that prevents errors from occurring or makes them immediately obvious.
- Memory Safety - A property of programs and programming languages that prevents code from reading or writing memory it shouldn't, which removes entire classes of bugs such as buffer overflows and use-after-free.
- Make Illegal States Unrepresentable - Design your data types so that invalid combinations of values simply can't be created, and let the compiler catch a whole class of bugs for you.
- Option Type - A type that makes the possible absence of a value explicit: a value is either present (Some(x)) or absent (None), and the compiler forces you to handle both cases.
- Newtype Pattern - A technique that wraps an existing type (often a primitive) in a new, distinct type, so the compiler can tell apart values that share a representation but mean different things.
- Correct by Construction - Build software so that correctness follows from the way it's put together, instead of trying to find and remove the bugs afterwards.
← Back to all concepts