Re:Inheritance Often Doesn't Make Sense
by skybrian on Saturday March 17, 2018 @01:36PM
(#16608057)
Yes, and that's directly related to immutability. Immutable objects are timeless; their initial state is their final state. Any property that holds for their initial state can be encoded in the type and placed somewhere above it in the inheritance hierarchy.
You can think of a mutable object as a collection of immutable and mutable properties, where only the former can be moved into the type and become part of the type hierarchy.
This distinction isn't really about inheritance; it's more about what a type is in the presence of mutability. The type represents the invariants.
You can think of a mutable object as a collection of immutable and mutable properties, where only the former can be moved into the type and become part of the type hierarchy.
This distinction isn't really about inheritance; it's more about what a type is in the presence of mutability. The type represents the invariants.