Knowledge
Search knowledge... ⌘K
Knowledge · Anti-Patterns
Smell Mutable Data
Code smell indicating overuse of mutable state that makes reasoning about code difficult
Tags
refactoring-fowlercode-qualitymaintainabilitycode-smell2nd
Impact
Changes to data can often lead to unexpected consequences and tricky bugs. Functional programming is based on the notion that data should never change and updating a data structure should always return a new copy with the change, leaving the old unchanged. Even when not going fully immutable, limiting where data changes occur makes code easier to understand and reduces the opportunities for bugs.
Symptoms
- Changes to data can often lead to unexpected consequences and tricky bugs. Functional programming is based on the notion that data should never change and updating a data structure should always return a new copy with the change, leaving the old unchanged. Even when not going fully immutable, limiting where data changes occur makes code easier to understand and reduces the opportunities for bugs.
Source
Martin Fowler — Refactoring: Improving the Design of Existing Code, 2nd