It’s what they told you about OOP that sucks

These days it seems to be fashionable to say that “OO sucks”. Why OO Sucks by Joe Armstrong.

We already read argumentations like this. That’s why the almighty Giuseppe Mazzapica titled one of his presentation

What they told you about OOP is wrong

This is also the case: dear Joe, your remarks are based on assumptions that often are not true.

Let’s see them:

  1. “Data structure and functions should not be bound together”. This assumes that functions have ominiscent knowledge of their input. I found the concept of Abstract Data Type really useful
  2. “Everything has to be an object”. Well, in a computer everything is a sequence of bits. How we interpret them and what they represent is another matter. An object is what a sequence of bits represents and the (basic) operations we can do on them.
  3. “In an OOPL data type definitions are spread out all over the place”. That’s usually because people make bad design and “too fat” modules.
  4. “Objects have private state”. Also functional programming languages have private states. They just call turn it into an argument of the function. When you note that the typical OO notation joe.paint(a_box, yellow) turns into a_box = Painter_paint(joe, a_box, yellow) you are just a few steps away from a_box.add(my_pencil) which becames in a purely functional language such as Haskell

Data immutability is a nice concept, but tends to impact on performances. At least on Haskell it did.

Searching how Haskell handles state I discovered it has a really nice way to deal with units of measure. I shall find a way to implement it in Eiffel.

Summarizing, I would re-study SOLID principles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.