DCI - Data, Context and Interaction - Successor to MVC?
Asked Answered
O

5

39

What is the best description of Data, Context and Interaction (DCI) to pitch it to an organization?

It's created by Trygve Reenskaug, the creator of the MVC-pattern.

Is it really the successor to MVC or just another pattern? And what are its pros and cons?

Oxtail answered 18/12, 2008 at 17:48 Comment(0)
F
17

The impression I got is that it's not a successor to MVC so much as a complement, for example figure 5 in the artima article on DCI has both. I think it's supposed to help make the distinction between model and controller more sane, or maybe between different part of the controller or different parts of the model.

The basic idea seems to be to split logic for particular actions our of your data classes and move it to traits/mixins/whatever, one per (user) action. You'll have many small pieces of code, instead of a few large pieces. Also, it sounds like adding new mixins is supposed to be "better" than adding functionality to your base classes. The code for individual actions will probably (I think?) be more spread out, but code for different actions should be more clearly and obviously separated.

Fitzger answered 21/3, 2009 at 17:1 Comment(2)
The code for individual actions will be less spread out, as they will be put into the contexts.Desquamate
The last part of the answer contradicts the goals of DCI. An explicit goal of DCI is to keep the parts of an algorithm in one place. Usually examplified by keeping the implementation of a use case in one placeQuartering
D
48

Trygve makes a presentation of DCI in https://vimeo.com/8235394

DCI has been created to solve a problem in object orientation: it's too difficult to review OO code.

The code for one use-case in OO is typicall spread out between lots of classes. To understand how the code works, you must also know the relationships between objects in runtime. These relationships aren't set in code, they depend on the situation.

What DCI proposes is that code for a given use-case is separated out from the classes and put into a different artifact called context. Objects of different classes can enter into a relationship in this context and take part in interaction where they have different roles.

The whole point of DCI is to make OO code more readable!

That's how I would pitch it.

Desquamate answered 27/8, 2010 at 5:48 Comment(2)
Yep +1 for the link. I was actually searching for itHayott
Nice answer, wanted to add by bit that one of the roles is to ease change in business logic as context represents the actual business logic and interactions among DUMB model objects. So it would be easy to change the business logic if it is present at one place, which will also reduce the amount of bugs introduced.Streaky
F
17

The impression I got is that it's not a successor to MVC so much as a complement, for example figure 5 in the artima article on DCI has both. I think it's supposed to help make the distinction between model and controller more sane, or maybe between different part of the controller or different parts of the model.

The basic idea seems to be to split logic for particular actions our of your data classes and move it to traits/mixins/whatever, one per (user) action. You'll have many small pieces of code, instead of a few large pieces. Also, it sounds like adding new mixins is supposed to be "better" than adding functionality to your base classes. The code for individual actions will probably (I think?) be more spread out, but code for different actions should be more clearly and obviously separated.

Fitzger answered 21/3, 2009 at 17:1 Comment(2)
The code for individual actions will be less spread out, as they will be put into the contexts.Desquamate
The last part of the answer contradicts the goals of DCI. An explicit goal of DCI is to keep the parts of an algorithm in one place. Usually examplified by keeping the implementation of a use case in one placeQuartering
Q
5

A good question and an often occurring question. The short answer is that it's a paradigm on it's own based upon the founding ideas of OO by Kay, Dahl and others. It was created by Trygve Reenskaug as you note with several goals in mind. One of them being tha aim of making IO operations first class citizens of the program. (not IO as in disk operations but all communication between two different objects). Another important goal of DCI is to split what the system does (functionality/behavior) from what the system is (data)

Quartering answered 14/3, 2012 at 12:23 Comment(0)
M
1

I think improved system comprehension is a huge win for any organization, but you could also make the case that DCI is an improvement on MVC due to the following additional factors:

  1. Cleanly separating system behavior and data provides numerous benefits to data aggregation activities including more performant real time analytics due to smaller footprint of domain objects.
  2. Data object and behavior object reuse is much easier across functional divisions when they have their own place to live rather than being particulates as if randomly placed across a subset of the mixed data/behavior objects in a system.
  3. As BDD is becoming the defacto agile methodology, the organization will be leap years ahead of the rest of the industry in this practice and possibly a role model for other like minded organizations.
Muss answered 21/5, 2012 at 0:39 Comment(0)
I
-1

It totally looks to me as the Policy based design by Andrei Alexandrescu in Modern C++ design, however that work is more low level, DCI looks like an architecture with parts of methodology (use cases drive the design).

Icily answered 5/4, 2010 at 13:21 Comment(1)
You didn't answer the question.Desquamate

© 2022 - 2024 — McMap. All rights reserved.