What's wrong with OOP

ziggy on 2005-01-20T16:34:55

I saw this critique of object oriented programming via Lambda the Ultimate[1] today. The critique starts out good, with this opening:

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.
From here, the author, Richard Mansfield, walks down a well-worn path of overgeneralization, over-eager extrapolation, and frustration with poorly designed/engineered tools. Read between the lines, and this isn't a critique of OOP, but a critique of objects as expressed in Windows and C++. For example:
OOP actually originated to assist in a highly specialized kind of programming: modeling such natural phenomena as weather patterns. But it got its major boost during the paradigm shift from DOS to Windows. With DOS, programs were linear. The user was guided through a series of steps, one after the other. With the advent of the Windows GUI, users were presented with a set of components on a desktop (text boxes, buttons, menus, and so on). The user got to decide how often and in which order to activate the components. This desktop metaphor is easiest to manage if programmers embed programming and data such as size and position in each separate object, ready to respond to the user.
Clearly, there is more to OOP than weather simulations. I still run in fear whenever I think about how Windows apps work under the hood. (Cocoa, based on ObjC, is much easier to comprehend.) Throwing out OOP because C++ isn't exactly an OO programming language, or because Windows is a pile of crap is just a specious argument.

That's sad, because there really is a good position to defend here. Not all programming is suited for OOP. Sometimes, a procedural solution is best -- like shell scripts, quick one-page Perl hacks, or whatnot. Sometimes, a good object oriented interface really is the simplest, easiest and best way to describe or implement an interface (witness DBI and IO::All for just two examples). Sometimes a more functional approach is best (sort, map and grep).

It all comes down to this: there's more than one way to do it. As tchrist used to say, if you haven't studied the four main styles of programming (procedural, object-oriented, functional and logic), your education is incomplete. (paraphrased from memory)

 

[1] If my wife is reading this, I'm talking about the geeky lambda, not the GLBT community support group.


"if my wife is reading this..."

merlyn on 2005-01-20T17:17:27

So if you're wife is not reading it, you are talking about the GLBT organization?

My friends and I call that an "unnecessary qualification" and assess a five-yard virtual penalty in the conversation.

In fact, oddly enough, I came up with the five-yard penalty motif years ago when talking with a co-worker of your wife. {grin}

Re:"if my wife is reading this..."

delegatrix on 2005-01-20T21:29:41

He just likes saying 'my wife'. See ya soon.