I tend to cringe when I hear this particular debate, but I grin and bear it because it often ends up touching on a subject which I am much more passionate about: messaging.
Alan Kay’s stuff on messaging (see here on the brilliant c2.com) highlights the following top-two principles of OO:
- Everything is an object
- Objects communicate by sending and receiving messages (in terms of objects).
-------
Now, thinking about the garden variety C# (or even javascript) code I have to work with on a daily basis, the general idea is:
where the big circle bits are the “objects” which pass data (“A”, “B” and “C”) along the arrows. This diagram is quite UMLish in its conception, and it highlights the “objects” as the important bit.
If we think of circles “3” and “4” as being instances of the same class, then we could also draw a class-focused diagram like:
--------
But based on Dr. Kay’s principles above, perhaps we should think more like:
Here we see the messages “A”, “B” and “C” front and centre (and I think I mean message instances, not message classes), along with their usage pattern between instances of objects in the domain.
Hmm. This might be clearer with better diagrams. I’ll work on it.
No comments:
Post a Comment