Depending on who you ask, I use invariants simply because it makes life easier. Learning invariants are like learning blind input. Every time you use an invariant, you know more about your code. If you insert the invariant as a comment into your loop, this helps the LOT reader. I would say that using invariants makes the creation and maintenance of source code much cheaper and allows you to create much more complex algorithms that are still supported.
And unlike OOP, I have never experienced anyone wasting time using invariants.
source
share