Invariants guide the structure and behavior of a class.
Invariants dictate necessary conditions for maintaining object integrity, influencing how a class manages its data. For instance, a ShoppingCart class may have an invariant that total weight cannot exceed a certain limit, affecting how items are added and requiring checks in addItem methods.