This rule is Obsolete | |
Synopsis: | If the behavior of an object is dependent on data outside the object, this data is not to be modified by const methods |
Language: | C++ |
Severity Level: | 9 |
Category: | Class Interface |
Description: |
Although, the data exists outside the object it is still part of the state of the object. For example, when a state machine is implemented using the state pattern (see [Gamma]), a const method in the encapsulating class is able to call non-const methods on the state classes. However, data contained within the state classes should not be changed in this scenario. |
Literature References: |
Ellemtel Rule 24 |