Re:Why Are So Many Developers Hating on Object-Oriented Prog...
by AnimalMuppet on Friday August 23, 2019 @11:52PM
(#20785113)
In my opinion, C++-style OOP was a solution to a particular problem: Here's a procedural program. It's got some data. That data is grouped together for convenience in, say, C-style structs. The problem is that any function in the entire program can modify the data in the structs. When the data goes bad (self-inconsistent, say), that gives you a lot of places to look. Someone wrote a function that doesn't maintain the data in a consistent state, and it could be anywhere. In a 10-million-line code base, that could be a long search.
C++ classes changed that. Nobody gets to modify the data except member functions (presuming no inheritance). Maintaining the consistency of the data is easier, because there's a very limited number of functions to look at to make sure they preserve the invariants.
With inheritance, you can still do that for the parts that you make private.
Now, is that the ultimate answer to how to do software development? Perhaps not. It was a step better than the way things were before, though.
C++ classes changed that. Nobody gets to modify the data except member functions (presuming no inheritance). Maintaining the consistency of the data is easier, because there's a very limited number of functions to look at to make sure they preserve the invariants.
With inheritance, you can still do that for the parts that you make private.
Now, is that the ultimate answer to how to do software development? Perhaps not. It was a step better than the way things were before, though.