3 ms·
What other paradigm focuses on components with encapsulated state? Definitely not functional! Isn't any nounish "thing" with state an object anyways? Why else c
by seanmcdirmid 9y ago
What other paradigm focuses on components with encapsulated state? Definitely not functional! Isn't any nounish "thing" with state an object anyways? Why else could it be?
- di4na 9y agoBecause there are no "nounish" things. It is a false construct. Also see Actor model or "out of the tarpit". Also Barbara Liskov "Programming with Abstract Data Type". Encapsulating state instead of behaviours is a mistake.
- seanmcdirmid 9y agoHewitt never said actors weren't objects, quite the opposite actually. Heck, simula (the first OOP language) objects were very actor like. Grand parent is talking specifically about encapsulating state and not just behaviors.
- di4na 9y agoSimula objects were not a Actor like, they were exactly like today object. Smalltalk originally was like Actors, and it is what spawned the idea in Hewitt mind. Our Objects of today come straight from Simula. Edit : and yes, there is a reason i said behaviour and not state. Objects are bad at encapsulating state, because you do not encapsulate state like that.
- seanmcdirmid 9y agoSimula objects ran as coroutines.
- willtim 9y agoContrary to popular belief, OOP doesn't really encapsulate state, it just hides it. Encapsulated state should mean state that does not contribute to the global state space of the system. The danger of OOP is that one ends up with a combinatorial explosion of possible states your system may be in. This may be desired in some situations (e.g. simulations) but does not make a good general approach. Note that functional languages are also capable of building stateful systems this way, for example Erlang actors or composing finate-state automata.
- naasking 9y ago1. You don't want components with encapsulated state at every level of your system. 2. Where you do want them, like at coarser service boundaries, virtually all general purpose languages have modules of some sort.
- seanmcdirmid 9y ago1. Sure, most system are not made purely out of functions or purely out of objects. 2. If a module has state, is it not named with a noun, is not an object even if we try calling it an entity, an actor, or anything else?
- naasking 9y ago> If a module has state, is it not named with a noun, is not an object even if we try calling it an entity, an actor, or anything else? But we're talking about OOP, which is characterized by specific logical properties surrounding modelling, encapsulation and extension, not about colloquial terms like "objects" that are referred to by nouns. Conflating colloquial language with the programming language is one of many reasons why OOP seems seductive but is often misleading.