Questions tagged [dci]

Data, Context, Interactions (DCI) DCI was invented by Professor Trygve Reenskaug to solve a specific problem in OO code; it's very hard to read OO code for a specific use-case since it is often spread across many different classes, and the control flow between the methods of these classes depend on which objects are instantiated to which variables. With DCI Reenskaug proposed a new way of coding for use-cases where each use-case is implemented as a

Data, Context, Interactions (DCI)

DCI was invented by Professor Trygve Reenskaug to solve a specific problem in OO code; it's very hard to read OO code for a specific use-case since it is often spread across many different classes, and the control flow between the methods of these classes depend on which objects are instantiated to which variables.

With DCI Reenskaug proposed a new way of coding for use-cases where each use-case is implemented as a Context and each participating object has a Role in that Context.

Methods can be written for the Context and for the Roles. The Role-Methods are considered instance methods of the object playing the associated Role. A RoleMethod exists only in the scope of a context. When an object no longer plays a role, the RoleMethods are no longer part of the object

This approach allows the code for a given use-case to be organized in the Context construct and can easily be read and understood as a complete artifact.

DCI is not a pattern that can be easily implemented in any OO language, it is more of a suggestion for the next evolution of the OO universe. For most languages new keywords would have to be added. Reenskaug has however done an implementation of DCI in SmallTalk and a language call Marvin has been design and implemented with the support of DCI in mind.

To learn more look at the community site for DCI called fullOO

31 questions
3
votes
2 answers

generic duck typing in F#?

using let inline and member constraints I'll be able to make duck typing for known members but what if I would like to define a generic function like so: let duckwrapper<'a> duck = ... with the signature 'b -> 'a and where the returned value would…
Rune FS
  • 21,497
  • 7
  • 62
  • 96
2
votes
1 answer

DCI and Use Case Slices

In his book "Aspect-Oriented Software Development with Use Cases" Ivar Jacobson introduces "use case slices". It seems that DCI and use case slices are based on the same (or at least similar) idea. What are the differences between DCI and use case…
Stefan Papp
  • 2,199
  • 1
  • 28
  • 54
2
votes
1 answer

Responsibility of a DCI Context?

The methodful roles contains the actual algorithm, but what should the Contexts executing method do but execute one of those methods? public class SomeContext { // ... Constructor omitted ... public void Execute() { // Is this…
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
2
votes
1 answer

DCI, should a role add properties to data objects?

I've been playing around with DCI after following along with The Right Way to Code DCI in Ruby. I find that I keep wanting my roles to add properties to my data objects. For instance, if I have a user object. class User def initialize(name) …
JonMR
  • 586
  • 3
  • 18
1
vote
3 answers

Ruby precedence of methods in objects extended with multiple modules

Given the following: class User; attr_accessor :roles; end module RegisteredUser def default_context Submission end end module Admin def default_context Review end end current_user = User.new current_user.roles =…
Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
1
vote
1 answer

DCI, trouble with concept of 'context' and what roles within know of each-other

I may just be missing a key concept here. I understand the 'dumb' data objects. I also understand that roles are stateless collections of methods applied to a dumb object when it takes on that role. I also understand that a context assembles the…
Exodist
  • 629
  • 5
  • 15
1
vote
1 answer

What is a "pure object oriented language" in the context of DCI?

In DCI discussions, there is a usually mention of pure object oriented languages: Object-oriented programming languages—particularly the "pure" ones—expressed everything in terms of objects or methods on objects. (Of course, most programming…
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
1
vote
5 answers

Extending a ruby eigenclass to load CarrierWave

Update: I've simplified my question; you can see the full history by checking out my editing revisions. Thanks to iain and bernardk for getting me this far. I want to load carrierwave functionality into an instance of my User < ActiveRecord::Base…
neezer
  • 19,720
  • 33
  • 121
  • 220
1
vote
1 answer

Architecture for driving complex Use Cases

I'm about to design a software to be implemented by several developers. The software has many complex use cases involving several steps and commands from the UI. I want to have a clear separation from the UI and the Bussiness logic, so, the…
user1275011
  • 1,552
  • 1
  • 16
  • 36
1
vote
1 answer

Error handling in DCI context?

If I'm using ASP.NET MVC framework, instantiating a Context and something goes wrong in there, is it ok to throw an Exception and let the Controller handle it? And then for nested contexts, can the outer context catch exceptions thrown by the inner…
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
1
vote
1 answer

DCI context in a web application

I'm thinking how and when a DCI context can be used in a Web application. I'm considering this high-level use case: User enters city, arrival, departure, room type and clicks "Search". System displays a list of hotels User clicks on a Hotel logo…
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
0
votes
1 answer

Using inheritence to simulate roles in C++ for DCI

I have been trying to learn about DCI (Data Context Interaction) (http://tidyjava.com/dci-architecture-visionary/) It seems to me that 'roles' can be simulated by creating derived classes which inherit from a base class and have access to all the…
blippy
  • 1,490
  • 1
  • 13
  • 22
0
votes
2 answers

What is Thread.current for in the DCI in Ruby example?

What is Thread.current for in this code? I'm looking at this example of using DCI in a Rails application. In lib/context.rb, there's this: module Context include ContextAccessor def context=(ctx) Thread.current[:context] = ctx end def…
Jared Rader
  • 850
  • 6
  • 21
0
votes
1 answer

How to handle exceptions in DCI

Imagine that you have a context that handles money transfers between user's accounts. class Account < ActiveRecord::Base belongs_to :user end class MoneySender < SimpleDelegator class NotEnoughBalanceError < StandardError ; ; end def…
GuidoMB
  • 2,191
  • 3
  • 25
  • 40
0
votes
1 answer

Ok to have unbound roles in a DCI Context?

I'm working on a CreditCardPayment context, and found this possibility that not all roles are needed for some context methods. For example, the method CreateSecurityHash may require all roles, but VerifyHash only requires one. Is it ok not to bind…
ciscoheat
  • 3,719
  • 1
  • 35
  • 52