Refactoring to Immutability
summary
Shows concrete refactor steps: replace singletons by pass a clock or a time value so tests become pure, turn setters into replace setters with with-methods that return new value objects, and swap mutable collections for persistent collections (shared tails, tree sharing) to avoid full copies. Explains a quadrant (shared/unique × mutable/immutable) that pinpoints when locks are necessary, gives a stack example implemented immutably, and notes performance and GC tradeoffs.
AI-written summary · about
chapters (14)
- 0:00The case for immutability
- 1:45Understanding moving parts
- 5:11Achieving reasonable code
- 8:17The problem with global state
- 12:14Quadrant of synchronization
- 14:48History of concurrency
- 17:56Architectural refactoring
- 21:06Breaking singleton habits
- 25:01Refactoring dependencies
- 29:42Value object design
- 34:07Transforming state
- 39:26Persistent data structures
- 44:21Immutable collections
- 51:08Dataflow and conclusion
related talks
32mDesigning With Immutability
43mWorking efficiently with immutability
10mFunctional Programming for Everyone
34mImmutability: Putting The Dream Machine To Work
42mThe Mutable State Monster and How to Defeat It
48mMutable or Immutable? Let's do both!
13mThe Record: Migrate to Immutability
03mLightning Talk: Ref, C++ const ref, immutable ref?
