Objects should not be left in an inconsistent state when exceptional conditions arise. Usual techniques for maintaining object consistency include:
- Input validation (for example, method parameters)
- Reordering the logic so that the code capable of resulting in the exceptional condition, executes before the code that modifies the object executes
- Through the use of rollbacks, upon intercepting a failure notification
- Performing required operations on a temporary copy and committing changes to the original object, after their successful completion
...
Failing to restore prior object state on method failure can leave the object in an inconsistent state.
Rule Guideline | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXC11-J | low | probable | high | P2 | L3 |
...