- 17.01 (latest) ...
A function should never change the state of an object. A function containing a procedure call, an assignment to an attribute, or creating an attribute is a strong indication that this principle is violated. This rule applies exactly in these three cases.
There are rather exceptional but sometimes useful class designs in which the externally visible state of an object (i. e. the values of exported queries) does not change even though the function contains a rule-violating instruction.
Scope Class Status Enabled Severity Warning Applicability All Score 60
Example of violation
Ensures that no query changes the state of the current object.
In the example, one could replace the routine
width by an attribute and calling
update_width before querying
update_width would be:
Or you can remove the line
height := height + 10 from the body of
- Parent <Rules>