|
This article is about class invariants in computer science; for use of the term in mathematics, see equivalence class and invariant.
In computer science, a class invariant is an invariant used
to constrain objects of a class. Methods of the class should preserve the invariant.
Class invariants are established during construction and constantly maintained between calls to public methods. Temporary breaking of class invariance between private method calls is possible, although not encouraged.
|