| ▲ | senderista 5 hours ago | |||||||
The essence of OOP to me is message-passing, which implies (hidden) local mutable state (there must be local state if a message can change future behavior). (Really, actor-based languages are purer expressions of this ideal than conventional OOP languages, including Smalltalk.) However, encapsulation is not at all unique to OOP; e.g. abstract data types are fully encapsulated but do not require all function calls to look like message passing. | ||||||||
| ▲ | elcritch an hour ago | parent | next [-] | |||||||
IMHO the real key of message passing is localized decision making on a specific instance of data. Similarly message passing allows an actor to decide how to respond to an event, to forward a message, to ignore it, etc. That's possible but more difficult to achieve with Java/C++ "straightjacket" style OOP. Important patterns for GUIs like the Observer pattern are just simpler with a message passing paradigm. | ||||||||
| ▲ | webstrand 2 hours ago | parent | prev [-] | |||||||
And to me it's just message passing, no inheritance, and with or without unobservable internal state. So long as you're calling procedures that are determined by the "type" of the object, whether dynamic or statically dispatched, it's OOP. Personally I'm against the practice of enforced state-hiding. I prefer the convention that state ought not to be depended upon, but if you do want to depend on it (sometimes important for composition or inheritance) you have tests to catch changes in the behavior of that state. And in practice there's often a state-machine of some kind hidden away inside various object types that you cannot avoid depending on. | ||||||||
| ||||||||