Skip to content

ALL-STAT1001 · state_ownership

Judge whether mutable state has one clear owner.

This is a contextual rule for all languages. Read its implementation.

Trace creation, mutation, aliases, exposure, synchronization, persistence, and lifecycle. State several holders reach is still owned when one explicit governing contract decides every write, whether that contract is a lock, a single writer, or a supplied protocol. shared names state several holders mutate with no such contract to point at, and leaked names internal state handed out for any caller to edit.

Findings cite state declarations, aliases, writers, readers, transitions, and synchronization.

Deliberate shared caches and framework state may be valid with bounded mutation and ownership.

Returning an internal mutable list that callers edit is leaked. An immutable snapshot updated through one repository is owned.

  • Cites “Fluent Python”, Object References, Mutability, and Recycling
  • Cites “Refactoring”, Global Data and Mutable Data
  • Cites “Programming Clojure”, immutable values and managed state