OOP And Hype

The Promise of Code Re-Use

Back in the day, Object Oriented Programming (OOP) held out a great promise: code reuse and recycling. No more writing code and then having to reinvent the wheel, no more wondering how to do something you wrote code to do a few years back. The life of a programmer was going to be easy and glamorous from now on.

Turns out that didn’t happen. Promises like that almost never come true, and they sure didn’t in this case.

For one thing, you could write a bunch of straight functions and put them in a single file to achieve the same effect. Instant code re-use. We’d been doing that for years before OOP became a “thing” (though not as extensively back then).

The other thing is that programmers and organizations don’t always want to re-use code someone else’s written. They didn’t indent where you would want them to, they didn’t capitalize their variables right. Why did they do their loops that way? Why did they return that from the function? Etc. Then there is the “Not Invented Here” phenomenon, practiced by large corporations (Apple, Adobe and Microsoft come to mind) and the like. If it wasn’t invented, stolen or bought by us, we don’t want any part of it.

OOP certainly didn’t deliver on this, its chief promise.

The Supposed Advantages of OOP

I’m not a language geek, nor an authority on computer languages. I’ve coded in BASIC, Pascal, C, C++, FoxPro, Perl, Python, PHP and Javascript. I’ve studied a few other languages like APL, COBOL, Fortran and RPG. The following discussion springs from my knowledge of these languages, and others of their ilk. If you want to talk about Smalltalk, Lisp, Haskell or other more exotic languages, my assumptions may be off. So that’s why I limit the discussion to the assumptions underlying the languages I know.

The following are the chief supposed advantages of OOP.

The real advantages of OOP

I’m not particularly a Luddite or someone who likes to disagree just to stir the pot. Quite the opposite, in fact. I’m also a programmer who is painfully aware of the potential for over-use and waste of computer CPU time and memory. So, for example, on a PHP program intended to show a single screen with a form on it, I can’t see a reason to call in 150 code files, 20 calls to backing store, and a partridge in a pear tree in the process of displaying that one page. If I see that happening, I know I need to refactor my code. And I don’t much care for unwarranted hype. And I still see a lot of unwarranted hype around OOP. Even after years of experience which disprove most of the claimed benefits of OOP. I also don’t mind digging into code with both hands and feet, if necessary, if I think the code is too abstracted from the data and objects it represents.

Don’t get me wrong. I use classes and objects all the time in my PHP programming. But I use them primarily for the two main benefits I cite above. Otherwise, OOP isn’t of much use to me. I’m a practical guy, and pie-in-the-sky claims don’t impress me. Show me the code.