SE450: Encapsulation: Invariants, Preconditions, and Postconditions [18/47] |
Definition: the interfaces of classes are viewed as contracts that specify benefits and obligations of both the client and the supplier (the class itself). (Bertrand Meyer)
We can enhance interfaces by using preconditions/postconditions and invariants:
You can define these conditions as constraints in the
UML. Just put the text describing the constraint in { }
.
There is also a more formal Object Constraint
Language available to define constraints.