4 ms·
I don't follow why objects need an identity, as you define it. How does not having an identity make something un-objectlike?
by lacampbell 9y ago
I don't follow why objects need an identity, as you define it. How does not having an identity make something un-objectlike?
- seanmcdirmid 9y agoI would say identity is core to objectness. Without identity, something is purely structural, only its value is relevant because it will not transition to another state later. Objects must be things you can manipulate. They have a presence beyond their values.
- lacampbell 9y agoI use objects that can't transition from one state to another practically every working day. It's a strange view point to me that because something is immutable, it's not really an object. But a view worth thinking about. To me the important thing is hiding internal state and sending high level messages instead of something like "change internal field x to y". Whether that internal state you're hiding is immutable or not seems irrelevant to me.
- seanmcdirmid 9y agoIf you have a variable X that is pointing at different immutable maps over time, then X is the identity of your object that is implemented with multiple immutable maps.
- spdionis 9y agoBecause 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.