by Leon Rosenshein

OOP Isn't Dead

I've been hearing that object oriented programming is dead for a while now. Like 15 years or so. But I don't believe it. I don't believe it for a bunch of reasons, but the simplest are that it's still around, and it's still useful.

That's not to say that there aren't problems. There are problems with everything. With OOP the problems can get pretty tangled and it can be almost impossible to sort them out without refactoring everything. Usually the problem can be traced back to one of two things. Either an explicit decision that everything is an object, or if only some things are objects, a poor choice of naming/segregation of the hierarchy.

When everything is an object nothing can stand alone. You want your objects to interact, so they need to understand each other, at least partially, Or you create some other object that knows about the different objects so it can handle the interactions. Despite your best efforts you end up with a big ball of mud.

For the second problem, having to make decisions with imperfect knowledge is a given, especially if you're being honest with yourself. And invariably something will come up that makes your current hierarchy less than ideal. Eventually you get to a point where what you really want is multiple inheritance, but that never works out well.

On the other hand, if you go back to how OOP was originally defined there's no mention of inheritance or polymorphism. It was defined as a group of small things that communicated by message passing, or, in today's language, a distributed system of microservices.

And if you consider a function call and return as message passing (which it is), then there's still a lot of life left in OOP. What OOP is really about is encapsulation, decoupling, and late binding, which are all things that make your system more stable, easier to test, and more resilient to change.

So the next time someone tells you OOP is dead, tell them no, we're just now actually getting to use it they way it was intended.