35 ms·
It seems to me that this is all about access to data (state). Pre-OO (and FP), we had structured programming, where the data lived in variables or structs, and
by AnimalMuppet 10y ago
It seems to me that this is all about access to data (state).
Pre-OO (and FP), we had structured programming, where the data lived in variables or structs, and anybody at all in the entire program could alter the data. That turned out to be difficult to maintain, because if the data wound up in a bad state, any line in the program could have changed it.
OO (as typically used) meant that an "object" owned the data, and nobody else could touch it. That meant that, if the data wound up in a bad state, only a very small section of the program could have (directly) changed it. That was a huge improvement.
In (pure) FP, the data disappears. You don't talk about it directly (except within one function, where you have bindings to it). The data disappears into the plumbing (the connections between functions), and nobody changes it. If it was computed correctly when created, it's correct forever, because nobody can change it.
In this sense, both FP and OO are trying to solve one of the biggest problems with the old structured paradigm.