Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Alan Kay Was Wrong (About Him Being Wrong)

DZone's Guide to

Alan Kay Was Wrong (About Him Being Wrong)

Is the term ''object'' misleading in the world of OOP? Should it be considered something more akin to ''messaging''? It depends on which level you're working on.

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

From time to time, someone asks me what I think about what Alan Kay, the father of OOP, the designer of Smalltalk (the first object-oriented language), said in 1998 about OOP. He literally said that the very term "object" was misleading, and that a more appropriate one would be "messaging." Here is what I think.

I believe that there are two orthogonal means of interaction between objects: messaging and composition. Let's say, we have a point and a canvas:

Point p = new Point(x, y);
Canvas canvas = new Canvas();


This is how messaging would look:

p.printTo(canvas);


The problem with messaging is that it keeps objects on the same level of abstraction. They communicate as equal and independent "modules," sending data messages to each other. Even though they look object-oriented, the entire communication pattern is very procedural. We try to encapsulate as much as we can inside a single object, but we inevitably still have to expose a lot of its data in order to be able to "connect" it with other objects.

We turn objects into "little computers," as some books refer to them. They expect data to come it, process the data, and return back some new data. The maintainability problem is not really solved with this approach — we still have to deal with a lot of data, remembering its semantic outside of the objects. In other words, there is no true encapsulation.

On the other hand, this is how composition would look instead:

Point p2 = new PrintedOn(p, canvas);


Every time we need objects to communicate, we create a bigger object that encapsulates more primitive ones, letting them interact inside. Of course, the data will also go from object to object, but that will happen inside a bigger object. We can even make the encapsulator and the encapsulatee "friends", as I suggested before, to make that interaction more transparent and avoid data exposure through getters or even printers.

Let me quote Alan Kay again:

The key in making great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be.

It seems to me that he means modules, which are not objects. These are different things. Modules are elements of architecture, while objects are elements of design. These are two different levels. At the architecture level, we obviously need messages, and Kay's statement is perfectly correct. However, at the design level, we need composable structures to increase maintainability — and messaging is not what can help us achieve this goal.

Thus, I believe Alan Kay was right when he invented objects, called them objects, and gave their programming style the "object-oriented" title.

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:
encapsulation ,object-oriented language ,oop ,messaging ,java

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}