Do you use invariants when programming?

I am doing an intermediate programming course that emphasizes the use of invariants. I have never used them before, and they seem to take longer to create. Does the software industry reflect the use of invariants?

+5
source share
3 answers

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.

+12
source

I don’t think about invariants very much - not as much as pre / post-conditions. To be honest, I should think about invariants.

, , - - OO, , , : , .

, ... , . , . , , .

+8

, , . , . , . , . , , . , , , :)

+3

All Articles