No Time To Play

Object Oriented Stupidity

by on Apr.09, 2015, under Off-topic, Opinion

Allow me to get philosophical for a moment.

It occurs to me that a tomato isn’t a tomato because Zeus has decreed so. We only call it a tomato because it has a particular combination of properties. Its name comes from its properties, not the other way around. So object-oriented programming has it exactly backwards…

Then again, this is the same brain bug that causes lawmakers to ban tactical knives when kitchen knives are just as dangerous, and in fact any object with a sharp edge can cut, while any object with a sharp tip can stab, regardless of what we call it or what it was built for. Think an ice pick.

On a related note, it occurs to me that a car doesn’t drive, while a triangle doesn’t draw. So writing and triangle.draw() is just nonsensical. Sure, nowadays a car can drive itself, but it’s still a transitive verb.

I sometimes make fun of Haskell, but it may well be the only programming language with a sane object system…


2 Comments for this entry

  • fluffy

    Of course most OO graphics frameworks don’t work in the “triangle.draw()” way anyway – you have a canvas of some sort that you submit primitives to. So it’s more like canvas.draw(triangle). Which is still a mixed metaphor but at least it’s got a reasonable control flow (and which makes it much easier to abstract stuff away on heterogenous platforms).

    And, to that point, I think that makes for a pretty good sniff test for whether an OO design is sensible or not.

    • Felix

      Indeed! Thankfully, people who design graphics frameworks know better than whoever designs OOP courses. I’ve seen people putting exactly the “triangle.draw” kind of code in real-world apps. It’s a scary sight.

Posts by date

April 2015
« Mar   May »

Posts by month