I know there's a technical term for this and for the life of me I can't remember it:

When designing a class (or some kind of thing with a functions and data), each call to the object's methods should leave the object's data in a consistent state. "Consistent" means in accord with a series of (hopefully documented, usually not programmed in) constraints called [X]s.

有帮助吗?

解决方案

I think you're getting at "invariants".

Preconditions are things that must be true prior to a method execution. Invariants are things that are always publicly true, and post-conditions are things true following method execution.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top