Stage 1 · Lesson 7 of 8
Value objects and immutability
A is defined by its values rather than an identity. Two Money objects holding 10 US dollars are equal, and it does not matter which one you have. Making it means it never changes after creation: adding money returns a new Money object instead of changing the old one.
Immutable objects can be shared freely, between too, because nobody can change them behind your back. Small types like Money, Email or DateRange also carry their own validation, so a bad email cannot exist anywhere in the program. Every language on this roadmap has a short way to write them.
Common trapmarking a field final or readonly while it holds a mutable list, so the "immutable" object can still change underneath you.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking the Object Oriented Design Interview
Design Gurus · Intermediate · Subscription
Its opening chapters teach the four OOP ideas applied inside real designs, with UML and running code
- CourseFreeMIT 6.102: Software Construction
MIT · Intermediate
Free MIT readings: Abstract Data Types, Rep Invariants and Interfaces and Subtyping are this stage at university depth