All lessons in Software Engineering: Programs, Systems, and Maintainable Software
Program State, Aliasing, and Resource Ownership
Trace shared mutable objects and make ownership and cleanup behavior explicit.
35 minutes · Free with an account · preview
What you will learn
- Trace names, objects, and aliases through a mutation.
- Identify which operation owns cleanup for a resource.
- Replace an ambiguous shared-state contract with an explicit one.
A function receives a list of active loans and returns a filtered report. Later, another part of the program discovers that its original list has changed. The function may have sorted or removed elements through a reference shared with its caller. The defect is not mysterious once you distinguish the name of a value from the object it refers to.
State reasoning is the foundation for debugging collections, caches, domain objects, and resources. The exact syntax varies by language, but you can always ask what is stored, who can observe it, and which operation may change it.