3 ms·
How do you know when it's a misapplication? What do these constructs actually model?
by ogogmad 4y ago
How do you know when it's a misapplication? What do these constructs actually model?
- deleted 4y ago[deleted]
- Banana699 4y agoState Machines. Objects are supposed to model state machines, each mutating method is a transition event that takes the current state and any number of arguments and transition the state machine to a new state. In very simple words, each object in an OOP program is a virtual computer, its class define the instruction set. "Objects are a recursion on the notion of computer itself" --Alan Kay
- ogogmad 4y agoSounds profound, but I don't know why you'd want to use this metaphor heavily.
- astrange 4y agoState encapsulation is useful insofar as, if you wanted to write a proof that those pieces of state were only ever set correctly (eg using a statechart), you can now do that. OOP languages never actually include this because nobody seems to particularly care if their code actually works.