3 ms·
Because objects are supposed to hide their internal state and the actions you do with them are heavily dependent on that state. This means that an object must h
by spdionis 9y ago
Because objects are supposed to hide their internal state and the actions you do with them are heavily dependent on that state. This means that an object must have an identity to be sure you're working with the right object.
If you don't have identity it means that you must know yourself what state you're working with. This defeats the definition of objects that says that their state is hidden.
- naasking 9y agoEncapsulation is not identity. Immutable objects are still perfectly encapsulated, but they don't have identity, which is what the OP was asking about.
- lacampbell 9y agoI do come across the view a lot that immutable objects aren't really OO. It's something I really don't understand - state that changes over time doesn't seem like a key ingredient to me at all.