4 ms·
A good example would be a complex state machine, where you rely on the fact that the state is only modified by the state machine code to make sure it remains we
by fdupress 6y ago
A good example would be a complex state machine, where you rely on the fact that the state is only modified by the state machine code to make sure it remains well-formed, and the control-flow itself heavily relies on the state being well-formed (think of a TLS session, for example).
But then again, what you want there is modularity, which OOP provides, but is also well-supported in other paradigms.
- Gibbon1 6y agoYeah but you don't need OOP to do that. See opaque pointer's in a number of non OOP languages.
- augustk 6y agoThese are called Abstract Data Types.
- garethjrowlands 6y agoThis paper describes the differences between objects and ADTs, https://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOOPvsADT90.pdf https://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOO...
- billisonline 6y agoYou don't need OOP to do anything! But in the state machine example, it provides a coherent and readily understandable metaphor (object modifies its own private state; callers can tell it what to do but not how) for the task at hand. Isn't that the goal of a programming paradigm?