Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:15:59+00:00 2026-06-12T19:15:59+00:00

I recently saw the following presentation on DCI by Trygve Reenskaug : https://vimeo.com/43536416 It

  • 0

I recently saw the following presentation on DCI by Trygve Reenskaug :
https://vimeo.com/43536416
It kinda blew my mind. Mmmh, seeing in code the interaction between different components of a software is an attractive idea.

I tried to find examples of DCI in javascript, unsuccessfully. Then I started wondering. Isn’t the DCI pattern opposed to the evented programming pattern ?

Evented programming is trendy in javascript, i guess because it allows decoupling, and because classical inheritance concepts are not native to js. I think I understand the benefits of evented programming but I also noticed that debugging can be damn hard when it requires to follow event message.

Is it correct to say that both concepts are opposed ? Or did I got it wrong ? Is there some example implementations of DCI in js that I missed ? What should I look at in order to dig the concept ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:16:00+00:00Added an answer on June 12, 2026 at 7:16 pm

    Firstly event programming or inheritance are ortogonal to DCI. You can do DCI without inheritance and with event programing (or without).

    JavaScript is in somerespect one of the best languages to do DCI in. Most languages has some issues with following DCI stricyly. In JavaScript the issues are could be solved if there was a finalizer but the lack of a finalizer means you will have to “dispose” your self meaning some noilerplate code.

    I’ve written an example in JavaScript that I will put online on http://fullOO.info where you will find the examples Trygve, Jim and I have created together with some other people have created as well.

    fullOO.info is also the answer to where you could go to get more familiar with DCI or you can join object-composition a google group for discussion regarding DCI.

    The example I’ve written in JS is the canonical DCI example money transfer and the interesting part (that is everything but boilerplate/library code) can be seen below:

    var moneyTransferContext = function(sourcePlayer, destinationPlayer, amount) {
        var source = {
                withdraw: function() {
                    var text = "Withdraw: " + amount;
                    this.log.push(text);
                    this.balance -= amount;
                    console.log("Balance: " + this.balance);
                }
            },
            destination = {
                deposit: function() {
                    var text = "Deposit: " + amount;
                    this.log.push(text);
                    this.balance += amount;
                    console.log("Balance: " + this.balance);
                }
            };
        source = assign(source).to(sourcePlayer);
        destination = assign(destination).to(destinationPlayer);
        return {
            transfer: function() {
                source.withdraw();
                destination.deposit();
                return this;
            }
        };
    },
    sourceAccount = {
      log: [],
      balance: 100
    },
    destinationAccount = {
      log: [],
      balance: 0
    };
    
    moneyTransfer(sourceAccount, destinationAccount, 25).transfer().unbind();
    

    The rest can be seen at http://jsfiddle.net/K543c/17/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Weird Java Boxing Recently I saw a presentation where was the following
I recently saw the following implementation of enqueue for a BlockingQueue ( source )
I recently saw the presentation about the changes in ECMAScript 5 . And there
Recently I saw the following code that creates a class in javascript: var Model.Foo
I recently saw an interview question asking the following: Given a 32 bit number,
I saw recently following code: #define MY_ASSERT_CONCAT_(a, b) a##b #define MY_ASSERT_CONCAT(a, b) MY_ASSERT_CONCAT_(a, b)
I recently saw the following like structure can contains info on a buffer. I
I recently saw the following in the codebase: bool bRes = (a < b)
Recently, I saw the following piece of code in a python script: #!/usr/bin/env python
I recently saw a cool plugin on http://www.videobash.com/video_show/amazing-skater-11800 It's the vertical bar with all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.