My point of view about object oriented programming

Yesterday I read a post and watched a video criticizing object oriented programming in favor of a more procedural and if possible functional programming.

In summary what he says is that object oriented programming failed to delivery what have proposed and does more harm than good by force additional unnecessary complexity.

I agree in part with his position. Since I started to programming in Erlang, a functional programming language designed to high reliability and networking, I begin to see bad patterns in object oriented programming like Managers, internal implementation leaks, strong dependency between two apparently unrelated objects and others problems that gets worse with time.

I worked during three years on a project that had a large codebase and many developers working on it. I saw many times apparently simple decisions biting us back.

What happened was a component layers above or below broke because our change. Or what we expected to be there was implemented elsewhere l. Or our architecture not support a new feature without major restructuring. Sometimes we restructure to support it, but minor feature were just hacked in.

Another aspect that was difficult and many times impossible to solve was unit testing. I started to implement support to unit testing in our C++ code using Google Test. Implement test cases to leaf objects that have no dependency was easy. But when I started to climb our object hierarchy turned all most impossible to write test to manager class that internally used service locators and static references that you had no control whatsoever. We did instead was writing integration tests that cleanup everything and took dozen of minutes to finish.

Those problems I didn’t have in Erlang. All functions are pure and easy to write and run unit tests. In C++, C# and Java were a common issue.

Today I have no faith in object oriented programming. I’m very cautious when using it to avoid those traps.

However because object oriented programming is everywhere many developers only have experience on it. Most developers associate abstract data types to object, and most of projects and platforms are developed using object programming I think will be difficult to change this scenario.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s