A trivial mutator directly assigns an input to an instance variable. In legacy C++, this can accept invalid values, break the class invariant, and duplicate validation rules from the constructor. section 8.3
The pattern creates three practical problems:
- Unvalidated input lets clients place improper values inside an object. section 8.3
- Unnecessary mutability makes classes harder to read and can undermine correctness. section 8.3
- Repeated constructor and mutator checks can diverge as the code changes. section 8.3
A safer mutator validates candidate values before assignment. Centralizing that check in validateRadius lets both construction and modification enforce one class invariant without duplicating its rules.
