3 ms·
This is from formal methods, and while it is one way to specify your code, and contain unexpected behaviour, I wouldn't say it's the main thing in being a good
by jacknews 5y ago
This is from formal methods, and while it is one way to specify your code, and contain unexpected behaviour, I wouldn't say it's the main thing in being a good programmer. Managing complexity in general is perhaps the main thing, so that you can do more complex things without getting completely overwhelmed by details.
- ncmncm 5y agoInvariants are among the most powerful ways to manage complexity, although of course not the only ones. A type may be seen as a convenient packaging and naming of a collection of invariants.
- apalmer 5y agoI think outside of the formal logic space the concept of invariants still are core to programming. Many different strategies such as pure functions, unit tests, type systems, isolation of global state, all key really key around the concept that their are logical truths that always hold for a given program. This is a key way to build large complex programs. it’s impossible to hold every detail of what the code does, so having certain things be known truths goes a long way to enabling one to reason about code.