Michael Sokol

Software engineer's take on programing languages and paradigms. Talks about my open-source projects.
~ Sunday, July 3 ~
Permalink

Modeling DCI with UML

I can’t get enough of DCI. This paradigm is so simple yet elegant. I wrote a post a month ago about, a hands-on DCI with Ruby. Here, I’d like to take a step backward and try to think about ways to model it.

Modeling is important in my opinion. Its something that forces us to think. It should be simple and only focus on the big architectural choices. No need to include implementation details, or language specific behaviors.

In DCI, we have four entities to model. The data, contexts, roles and most importantly, the object. Since DCI is centered around the idea that the object is the main part of the equation, what kind of model would make sense?

If we take UML, the diagrams to model objects are the the sequence diagram, activity diagram, the communication diagram, and the interaction overview diagram. They are all relevant, depending which view we want to have.

According to the DCI paradigm, a class should be as dumb as possible. Ideally - and this is not what your mom told you about OOP - it should only have accessors and attributes. Why? Because the smartness comes from the roles. How can we model those?

Using UML, it’s possible to model it as a classifier having only methods. Now concerning context. Well, there’s a fascinating UML construct, also a classifier, the Collaboration. I’ve been pointed out to the UML Collaboration by Trygve Reenskaug in the DCI google-group.

Here is the definition from the UML (2.3) specification:

Collaborations are generally used to explain how a collection of cooperating instances achieve a joint task or set of tasks. Therefore, a collaboration typically incorporates only those aspects that are necessary for its explanation and suppresses everything else. Thus, a given object may be simultaneously playing roles in multiple different collaborations, but each collaboration would only represent those aspects of that object that are relevant to its purpose. 

The diagram above is taken from the UML specification. It’s interesting to see that the concept of role is tied to the notion of a collaboration.


 ()