So I recently stumbled upon an article about object oriented programming (OOP) that Bennett wrote about.
There were quite a few things that I didn’t agree with in his article, and I will go step-by-step onto why I don’t agree.
Some shops claim OOP success, but many I’ve spoken with are still “working on it.” Still trying to get OOP right after ten years? Something strange is going on here.
With the way the rest of his article goes, no wonder the people he talks to are “still working on it”. They don’t understand it!
Certainly for the great majority of programmers—amateurs working alone to create programs such as a quick sales tax utility for a small business or a geography quiz for Junior
I agree, amateurs that are working on a small sales tax utility don’t need OOP to do their job, but it is by far NOT the majority of programmers. Most applications in use are written by professionals that use OOP. Sure, there may be more programs written by amateurs, but how many people drive a car that is built by a teenager?
That’s why very few programming books I’ve read use OOP techniques (classes, etc.) in their code examples.
Those books are probably “Beginning C++ programming” or “Introduction to C”. (Yes, I realize the irony of the second title). They don’t teach OOP and don’t give OOP examples because OOP is an advanced technique that is difficult for amateurs to understand and grasp.
Consider the profound contradiction between the OOP practices of encapsulation and inheritance. To keep your code bug-free, encapsulation hides procedures (and sometimes even data) from other programmers and doesn’t allow them to edit it. Inheritance then asks these same programmers to inherit, modify, and reuse this code that they cannot see—they see what goes in and what comes out, but they must remain ignorant of what’s going on inside. In effect, a programmer with no knowledge of the specific inner workings of your encapsulated class is asked to reuse it and modify its members.
The idea is to not hide data that the programmer may have to use, but rather hide the data that the programmer will NOT have to use. They are considered private because it only pertains to that specific class, and they do not need to be inherited at all. They do not need to be understood at all by the inheriting classes. If they do, then that’s bad design!
A frequent argument for OOP is it helps with code reusability, but one can reuse code without OOP—often by simply copying and pasting. There’s no need to superimpose some elaborate structure of interacting, instantiated objects, with all the messaging and fragility that it introduces into a program. Further, most programming is done by individuals. Hiding code from oneself just seems weird. Obviously, some kind of structure must be imposed on people programming together in groups, but is OOP—with all its baggage and inefficiency—the right solution?
Wow, I don’t even know where to begin on this one. Copy and pasting? There are innate bugs in copy and pasting. What if a small portion of that needs to be fixed? Well, do you suggest you do a search and replace? What if you miss one? That leads to all sorts of maintenance nightmares!
Saying that most programming is done by individuals; what type of programming do you do? Most programming in the Real World consists of working in teams. I highly doubt that many major applications are written by solely one person. Maybe if you are doing hobby programming to make a sales tax utility, then that could be done by one person, but Firefox, Safari, IE, Opera… they are all made by teams of developers. And that’s just the web browser world.
Even after years of OOP, many—perhaps most—people still don’t get it. One has to suspect that we’re dealing with the emperor’s new clothes when OOP apologists keep making the same excuses over and over: you don’t understand OOP yet (it takes years of practice; you can’t simply read about it in a book); your company isn’t correctly implementing OOP, that’s why you’re facing so many programming delays and inefficiencies; you haven’t transformed your databases into OOP-style databases; and on and on. The list of excuses why OOP isn’t doing what it promises is quite long.
Sure, you may not fully understand OOP, but then why should someone that doesn’t understand it trying to implement it? If a company wants to do OOP, then a company should be hiring OOP programmers! I don’t try to understand assembly very well, and if my company were to tell me I need to do assembly programming, I would probably try my best, but most likely do it poorly when compared to the old school crowd. You work with what you understand and realize your limits.
Programmers describe it as little Ashley’s first birthday party: the computer starts counting from zero, so to the machine it’s her zeroth birthday party.
Correct me if I am wrong, but isn’t this a horrible analogy? Wouldn’t you consider her BIRTH DAY to be her zeroth birthday party?
All in all, I am in no way an OOP zealot, but I did not agree with a lot of what was said in his article. If you don’t agree with something that I have said, just leave a comment and it will promptly be deleted.