What are invariants, how can they be used, and have you ever used it in your program?
- by gablin
I'm reading Coders at Work, and in it there's a lot of talk about invariants. As far as I've understood it, an invariant is a condition which holds both before and after an expression. They're, among other things, useful in proving that loop is correct, if I remember my Logic course correctly.
Is my description correct, or have I missed something? Have you ever used them in your program? And if so, how did they benefit?