Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 9:05 AM
|
In this landmark article, Trygve Reenskaug and Jim Coplien describe DCI, an architectural style that aims to make object-oriented programs easier to use, understand, and maintain.
http://www.artima.com/articles/dci_vision.html What do you think of the ideas presented in this article? |
Posts: 20 / Nickname: raoulduke / Registered: April 14, 2006 11:48 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 2:39 PM
|
(basically i think the article was written with some sort of anti-news-style approach, which was frustrating to me. i'd have liked it even more if it did the progressive refinement journalistic style instead.)
|
Posts: 4 / Nickname: vijaykandy / Registered: January 25, 2007 6:08 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 4:17 PM
|
> What do you think of the ideas presented in this article?
The closest thing to writing something like this in Java is using Annotations right? You can inject some behavior with annotations but maybe not as elegantly as with a trait in Scala. It was a nice introduction to traits. |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 4:48 PM
|
> The closest thing to writing something like this in Java
> is using Annotations right? You can inject some behavior > with annotations but maybe not as elegantly as with a > trait in Scala. It was a nice introduction to traits. > The Qi4J folks are doing trait-like things in Java via a framework, so you may want to take a look at that: http://www.qi4j.org/ |
Posts: 20 / Nickname: raoulduke / Registered: April 14, 2006 11:48 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 1:22 PM
|
i respect the work here, so please don't take this quip as being too snarky, but... it kills me that it is as if functional programming never did and still doesn't exist! sheesh?!
|
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 2:27 PM
|
Hi Raoul,
> i respect the work here, so please don't take this quip as > being too snarky, but... it kills me that it is as > if functional programming never did and still doesn't > exist! sheesh?! > What part of DCI strikes you as sounding like functional programming? |
Posts: 20 / Nickname: raoulduke / Registered: April 14, 2006 11:48 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 2:32 PM
|
> What part of DCI strikes you as sounding like functional
> programming? overall, there are several things about DCI that sounds like things already said elsewhere, and it is a bit frustrating that the copious # of words were not better used to help give a sense of how DCI relates to things people already know, be it functional programming (the general idea that algorithms matter and should be able to be clearly expressed somehow in the ascii of the source code vs. the shattering that has happened via bog-standard oop), or context-oriented programming. |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 20, 2009 6:06 PM
|
I guess we tried to make the point that DCI tries to reproduce the convenience of algorithmic expression that procedural languages used to give us. Trust me, both of us are old enough to have been through them :-) We gave FORTRAN as a concrete example. I myself enjoyed doing a lot of FORTRAN programming in the 1970s. As the article says, DCI brings us the algorithmic expressiveness of FORTRAN combined with many of the good domain modeling notions from 1980s object orientation.
|
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 7:18 PM
|
@I guess we tried to make the point that DCI tries to reproduce the convenience of algorithmic expression that procedural languages used to give us.
Looking at Scala, Haller and Odersky have argued it is possible to build a system using event-based actors, allowing event-driven programming without inversion of control. See: http://lampwww.epfl.ch/~odersky/papers/jmlc06.pdf I'll quote their major criticism of *current* IoC techniques: Most programming models support event-driven programming only through in- What they really should have said, though, is that most IoC techniques are flowcharts in disguise. Containers like Seam actually realize this on some level and instead of disguising the flowcharts, design flowcharts into the Seam system top-down, with Subversion of Control and Seam bijection. Combined with declarative state management and tight integration with JSF and EJB 3, Seam code can be written in a conversational style. This is still not ideal, because it doesn't force programmers to do OO analysis. I feel like I'm writing an article in Harvard Business Review: "Brushing Teeth and Eating Veggies Surprisingly Good For Well-being." Figuring out how to force programmers to brush their teeth is an idea from an academic worth discussing. Let's start by explaining the bristles need toothpaste and the bristles scrub the teeth. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 7:47 PM
|
@overall, there are several things about DCI that sounds like things already said elsewhere, and it is a bit frustrating that the copious # of words were not better used to help give a sense of how DCI relates to things people already know, be it functional programming (the general idea that algorithms matter and should be able to be clearly expressed somehow in the ascii of the source code vs. the shattering that has happened via bog-standard oop), or context-oriented programming.
Not only have they been said elsewhere, but they've already been taken further toward their logical conclusions. For instance, I do a lot of dynamic composition where users can construct their own objects on the fly. Dynamic, run-time composition is essentially what the Open-Closed Principle is all about. Yet the real trick is *how* you provide dynamic composition. Some of my personal objectives are aimed at eliminating accidental complexity, because I find it eliminates the most lines of code. A really good barometer for complexity is the number of states in the system. For instance, coding something as orthogonal using and-decomposition of states when it is best represented using or-decomposition will significantly effect your program's statespace -- the orthogonal version is a CROSS PRODUCT. When will academics learn that it is no longer interesting to talk about single groups of functions in isolation, but instead focus on architecture and how they fit together as a whole? Those who have actually attempted this were bashed by Brooks' No Silver Bullet (Lieberherr and Kiczales [modularity], and especially Harel [complexity]). |
Posts: 2 / Nickname: culana / Registered: March 24, 2009 7:51 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 1:20 AM
|
Just a quick observation since this article tackles the problem of the user mental model vs. computer model:
Why does everyone insist on using Account Transfer as their primary example of system transactions? Mentally the user may picture some sort of ACIDic transaction going on, but implementation-wise: no bank accounting system I ever came across uses transactions for this use case - They all implement some variant of the Double Bookkeeping accounting principle; at best, you'll find a system transaction spanning the source account and some intermediary mother-of-all collection account (though not likely since most are of a different age). The target account is most frequently not at the same bank, and even when, the Double Bookkeeping principle is still used. Even what the balance is on the account depends on what you're after, as the bank knows several. In many ways, Banks implementation of the Account Transfer use-case is really closer to what is known as BASE: Basically Available, Soft State, Eventually Consistent; where end of day reconciliation ensures the consistency of the balance(s) on the account. As an example Account Transfer may explain to developers the mental model behind how transactions are supposed to work, but it does not help them translate the mental model into a working computer model. |
Posts: 2 / Nickname: roberth0 / Registered: March 24, 2009 4:28 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 9:37 AM
|
In the Scala example, the following is used to define a trait:
Now, I'm not that familiar with that language, so can someone explain whether this binds the trait to the Account interface? And if so, in the Java world, why not make TransferMoneySourceAccount a proper class and inject an Account instance into it rather than worrying about trying to mixin the trait into SavingsAccount? Thanks in advance. Robert |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 10:19 AM
|
That is actually not the worst form of coupling in the examples -- but it leads up to the big problem.
Here is all you need to see: new TransferMoneyContext(src, snk, 1000).Doit(); Christian was kind enough to provide a test harness (main()) to explicitly demonstrate the code smell. Jim didn't write the harness to give his example practicality. |
Posts: 2 / Nickname: horsdal / Registered: March 16, 2009 1:44 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 1:40 AM
|
>
> Here is all you need to see: > > new TransferMoneyContext(src, snk, 1000).Doit(); > As I'm sure you realize, this is actually just the command pattern: Some part of the application instantiates a context object, "remembers" the necessary domain objects in terms of the individual (context specific) roles. It is a design decision when/where to execute the context instance. As I see it DCI does not dictate how the split between instantiating and executing contexts is implemented. Or even if there is such a split. I dont see this as a code smell. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 0:45 PM
|
> >
> > Here is all you need to see: > > > > new TransferMoneyContext(src, snk, 1000).Doit(); > > > > As I'm sure you realize, this is actually just the command > pattern: Some part of the application instantiates a > context object, "remembers" the necessary domain objects > in terms of the individual (context specific) roles. It is > a design decision when/where to execute the context > instance. As I see it DCI does not dictate how the split > between instantiating and executing contexts is > implemented. Or even if there is such a split. > I dont see this as a code smell. You scenario is not event-driven. The fact you are reaching up the program's stack frame to grab objects to inject at a fixed point in execution is your code smell. The tip-off is the DoIT() method, and now also your use of "remembers" which can create scope impedance mismatches (hanging onto stale references). In addition, you have no scope guard for your command. How do you know if a multiple object interaction is valid? Trygve alleges DCI makes code simper to read. This makes code much harder to debug. |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 2:27 PM
|
>Trygve alleges DCI makes code simper to read. This makes
> code much harder to debug. I find it easier to debug because: 1.The context switches across business functions are fewer and more closely follow the mental model (role-based) than the programmer model (domain-based); 2. Inclusion polymorphism is almost completely gone. When I call foo I get foo: not one of many foos up and down the subtyping hierarchy. 3. I can find a test point for something of business value: that is, I can really do BDD. That makes it easier to develop test cases to support debugging. 4. I do less run-time debugging because the code is more readable at compile time. I do not understand your claim of why it's harder to debug. Do you have a running example? Try debugging the examples in the book manuscript. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 8:23 PM
|
> >Trygve alleges DCI makes code simper to read. This
> makes > > code much harder to debug. > > I find it easier to debug because: > > 1.The context switches across business functions are fewer > and more closely follow the mental model (role-based) than > the programmer model (domain-based); I am not sure this is proven. There is no direct comparison for me to understand your point clearly. > 2. Inclusion polymorphism is almost completely gone. When > I call foo I get foo: not one of many foos up and down the > subtyping hierarchy. I will agree that this is what most F# programmers hate about C# style languages. > 3. I can find a test point for something of business > value: that is, I can really do BDD. That makes it easier > to develop test cases to support debugging. Suppose I'm a robot and don't have as good of an imagination as I put on -- I burn my creativity at work. Explain this to me directly. > 4. I do less run-time debugging because the code is more > readable at compile time. > > I do not understand your claim of why it's harder to > debug. Do you have a running example? Try debugging the > examples in the book manuscript. Trygve's BabyIDE and Christian's test harness aren't pluggable, event-driven models. Trygve hardcodes sequences of collaborations in his mediator pattern usage. Christian does as well. Applications exist on multiple continuums, one of which is: <-[vague]-----[core data structures]-----[detailed]-> An architectural pattern should say stuff about these things. And so should good API design. Unfortunately, most APIs assume you know all your targets at code-write-time. My challenge to Trygve is to make such code more readable. It is easy to do a news report and explain what happened. It is much tougher to write poetry. It's my major complaint about MVC, too. People think *anything* in MVC can be a model, including a View. Clearer guidelines produce more robust designs than compiler features. Even though I hate DDD, this is the one reason it works so well!!! |
Posts: 2 / Nickname: rsm / Registered: March 24, 2009 3:58 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 5:26 AM
|
@There are five people in the world who remember everything that has ever happened to them.
I can't see a way for you to prove that exact number. Even if it's relevant do the article :) @It's my major complaint about MVC, too. People think *anything* in MVC can be a model, including a View. Clearer guidelines produce more robust designs than compiler features. I agree. Strongly. Both MVC and DCI need specific environments to run. The source code written in the spirit of MVC or DCI must be executed in the "context" of application executable, web server, operating system etc. The specific code could be treated as example of MVC or DCI not because of how it looks like but what it does. In FSM or Petri Nets there is a "magic hand" capable of changing states or passing tokens between channels and instances. In DCI, as for now, I can't see what is passed and where and how it is done. I assume, the "context" is passive element of the graph (node), the edges should be "roles" or "interactions", but what is the rule, responsible for decision on what element of the graph should I look at that particular moment of time? |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 1:08 PM
|
> In the Scala example, the following is used to define a
> trait: > >
> > Now, I'm not that familiar with that language, so can > someone explain whether this binds the trait to the > Account interface? > Good question. The " this: Account => " bit at the top of the trait is called a "self type," and what it does is give the this reference a different type than usual. In Java, the type of this is always the type of the class or interface you are defining. That's also true for classes in Scala, and is the default for traits, but with a self type you can give it a different type in a trait. When you say "this: Account => ", you are saying you want the type of "this" inside trait TransferMoneySourceAccount to be "TransferMoneySourceAccount mixed into Account ." Because of this the Scala compiler will let you call anything on the this reference that's defined in either the TransferMoneySourceAccount trait or in class or trait Account . And when you mix the trait into something, the Scala compiler will enforce that whatever you mix it into is at least an Account .> And if so, in the Java world, why not > make TransferMoneySourceAccount a proper class and inject > an Account instance into it rather than worrying about > trying to mixin the trait into SavingsAccount? > Your intuition is good (if I understand correctly what you're saying). One way you can think of self types is as a way to inject dependencies. The TransferMoneySourceAccount trait's self type says that the trait effectively depends on everything in Account . When you mix the trait into an Account , you are effectively injecting the trait's dependencies into it. You can actually take this quite far and do natively in the Scala language much of the dependency injection that requires an external framework like Spring or Guice in Java.
|
Posts: 2 / Nickname: roberth0 / Registered: March 24, 2009 4:28 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 6:47 AM
|
Thanks for the clear explanation of the Scala code. Having slept on the concepts for a night, I have a followup question which perhaps gets more to the heart of my inquiry.
Just how important are traits (or equivalent programming language constructs) to DCI? In the Scala example, we mixin the trait to the Account class. But it seems apparent that, at least for the article's example, we could implement the same in Java (without Qi4j) by injecting an Account into an instance of a TransferMoneySourceAccount. Or, to put it another way -- in certain dynamic languages such as Ruby (hand waving alert:I am no expert on Ruby), I believe we could do a mixin without an explicit coupling between the methodful role/trait and the Account object. Is this a real advantage? Does the Scala implementation lose something by coupling the trait to the Account? |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 2:06 AM
|
Hi Robert,
> Just how important are traits (or equivalent programming > language constructs) to DCI? In the Scala example, we > mixin the trait to the Account class. But it seems > apparent that, at least for the article's example, we > could implement the same in Java (without Qi4j) by > injecting an Account into an instance of a > TransferMoneySourceAccount. > > Or, to put it another way -- in certain dynamic languages > such as Ruby (hand waving alert:I am no expert on Ruby), I > believe we could do a mixin without an explicit coupling > between the methodful role/trait and the Account object. > Is this a real advantage? Does the Scala implementation > n lose something by coupling the trait to the Account? > I think a mixin in Ruby is an analogous concept to traits in Scala. The main difference comes from the fact that Ruby's mixins are dynamic and Scala's mixins are static. (In Scala, when you actually use a trait, mix it into a class, you can also call it a mixin.) As far as the advantage of traits over dependency injection in Java, I think you can get the same functionality, but you'll end up with more code in Java. You can write by hand in Java what the Scala compiler does for you when you mix traits into classes in Scala. It's just a lot more code in Java. But it is also a level of abstraction effect. I think all that code required in Java would make it harder to think at the level you think of in Scala when working with traits. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 9:27 AM
|
@As far as the advantage of traits over dependency injection in Java, I think you can get the same functionality, but you'll end up with more code in Java.
DI frameworks are simply boilerplate removal mechanisms. A more fair boilerplate comparison for DCI would be a mobile code framework such as Nat Pryce's Babble. |
Posts: 35 / Nickname: seanl / Registered: March 8, 2002 5:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 9:49 AM
|
I have great respect for the authors and I see the value in the style being promoted in DCI. I am struggling with the motivating example.
The authors were clear in demostrating that the traditional OO approach falls short in matching up to the user mental model (at least) in that an account ought not be smart enough to be resonsible for transactions and the like. But the example of extracting that behavior into a role that is then bound to the source account seems to fall sort as well. Assigning the transfer role to the source account seems arbitrary to me. Why not assign it to the target? Why assign it to either account? My mental model (admittedly I may be mental) is different from the example. I do have the two accounts and the notion of moving funds from on to the other. I diverge in that my mental model does not imagine the act of fund transfer being a role of either account. My model imagines that role belonging to the bank. This mismatch keeps getting in the way of my willingness to appreciate DCI. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 7:58 PM
|
@My mental model (admittedly I may be mental) is different from the example. I do have the two accounts and the notion of moving funds from on to the other. I diverge in that my mental model does not imagine the act of fund transfer being a role of either account. My model imagines that role belonging to the bank.
It's not "just you". I would go a step further and say the bank is a very high-level analysis class representing a large subsystem (and may not even be something the domain expert talks about in the problem domain), and that the analysis class for this scenario is a TransferSlip. OO textbooks do often present the Visitor pattern with a so-called pedagogical example of transactions with double-dispatch. I consider this an anti-pattern, however. |
Posts: 1 / Nickname: trinition / Registered: March 26, 2009 9:50 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 2:56 PM
|
I concur. I don't see why the responsiblity for orchestrating the transfer should belong to either the "source account" nor the "destination". This is similar to the age-old OO argument of whether it should be "cake.bake(oven)" or "oven.bake(cake)". Moving it from the source to the destination doesn't made it any better.
|
Posts: 1 / Nickname: arneadams / Registered: March 26, 2009 3:03 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 8:10 PM
|
Nice article.
But I don't understand the example with the TransferMoneySourceAccount. This algorithm operates on several parameters - the source account, the recipient, some anonymous transaction manager (having access to the database connection), a gui. Each of these parameters is necessary to carry out TransferMoneySourceAccount::transferTo. Later SavingsAccount inherits from TransferMoneyAccount - this makes the SavingsAccount a special parameter for the algorithm - it is accessible as "this" pointer after the most derived object is constructed. What about the other parameters? How can this design guarantee that recipient and gui are initialized properly after constructing the most derived object of TransferMoneySourceAccount? What is the rationale for making the transfer money algorithm a class and not simply make that algorithm a free standing template function that operates on source account, destination account and gui (assuming that the transaction manager is still accessible as singleton). |
Posts: 2 / Nickname: cyent / Registered: December 4, 2005 1:55 PM
Go back to Stroustrup's rule.
March 26, 2009 6:54 PM
|
The advantage about the heading to this article is you can immediately look at it and say... "User mental models vs Coupling and Cohesion" Ah! Whatever "Object" he is talking about is _not_ the Objects an Object Oriented compiler is talking about.
I'm not saying he is wrong, merely that he is not talking about compiler objects. OOP language "Objects" have some very hard mathematics driving the vital importance of... * Encapsulation * Information hiding * Protection of Invariants.(Law of Demeter) * Loose coupling and tight cohesion. * LSP ..in "language level" Object Design. http://www.artima.com/intv/goldilocks3.html Screw with them, and no matter how nice and understandable and nicely fitting with user mental models your design is, you have defective and fragile code. Having freed yourself from the mental coupling of compiler objects to whatever domain or analysis objects the article may be talking about.... we can continue to more reasoned discussion. Of course, it would be nice if people could come up with different names for these different things, define them clearly and then stick to them. Trouble is I think consultants thrive on the profits of confusion. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: Go back to Stroustrup's rule.
March 26, 2009 7:26 PM
|
@Trouble is I think consultants thrive on the profits of confusion.
It certainly seems that way. Jim wrote the forward to Selic's book Real-time Object-Oriented Modeling, which centered around software construction using state machines. Now state machines are "nerd-centric" and Jim can't be bothered to show me directly by comparison how his new approach is better. Despite the fact he clearly should know a ton about FSMs, since he wrote the forward to a book on my shelf about them. But, oh wait, I can buy/read his new book... which probably won't answer my question. The fact of the matter is I've yet to see a "DCI Architecture" fully working program that is event-driven and pluggable, so it is fundamentally not SOA or OO. So far it is compile-the-world procedural programming. Any "events" in DCI are hardcoded sequences of collaborations Steve Mellor calls The Mongo Controller Object Anti-pattern. |
Posts: 5 / Nickname: trygver / Registered: September 7, 2003 9:58 PM
Re: Go back to Stroustrup's rule.
March 26, 2009 11:45 PM
|
John Carter,
Thanks for your very enlightening comment: @The advantage about the heading to this article is you can immediately look at it and say... "User mental models vs Coupling and Cohesion" Ah! Whatever "Object" he is talking about is _not_ the Objects an Object Oriented compiler is talking about. @I'm not saying he is wrong, merely that he is not talking about compiler objects. OOP language "Objects" have some very hard mathematics driving the vital importance of... * Encapsulation * Information hiding * Protection of Invariants.(Law of Demeter) * Loose coupling and tight cohesion. * LSP ..in "language level" Object Design. This is exactly the problem. No, we are NOT talking about what you call "compiler ojects", we are talking about runtime objects. The term "object oriented compiler" is misleading IMO. It should be called a "class oriented compiler". An object has identity, state, and behavior. The class abstraction hides identity and only describes the other two properties. To me, an object is a runtime phenomenon that has a unique and immutable identity. The problem with class orientation as I see it is that a class specifies a set of indistinguishable objects. Without object identity, the class cannot describe the structures of communicating objects that the users interact with. The hard part of understanding DCI is to lift one's eyes from the class abstraction and open one's mind to an additional abstraction that applies to such object structures. This discussion reminds me of Dijkstra's "GOTO considered harmful" 40 years ago. People, including me, got really angry. GOTO was the essence of programming and his letter to the editor of CommACM was heresy. The man was crazy! It took me several months of hard work to get rid of GOTO from my mental model of what a program was. But the result was that my programs were greatly simplified and other people could actually read them! We are not asking you to get rid of anything from your mental model. We merely suggest that you add an object abstraction that augments the class and that retains object identity. We call it a Role. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: Go back to Stroustrup's rule.
March 27, 2009 5:32 AM
|
@This discussion reminds me of Dijkstra's "GOTO considered harmful" 40 years ago. People, including me, got really angry. GOTO was the essence of programming and his letter to the editor of CommACM was heresy. The man was crazy! It took me several months of hard work to get rid of GOTO from my mental model of what a program was. But the result was that my programs were greatly simplified and other people could actually read them!
NO. Just no. This discussion is not equivocal to "GOTO considered harmful". This discussion is equivocal to people asking you tough questions and you not being able to explain the answers. Instead, you are making excuses. Somebody has to put their foot down and simply tell you, "No." @The hard part of understanding DCI is to lift one's eyes from the class abstraction and open one's mind to an additional abstraction that applies to such object structures. So really what you are saying is "inclusion polymorphism considered harmful"? Sure, I can buy that, especially for "Object-Oriented Finance" applications like credit-default swap risk portfolio creation. Honestly, there is no need for the term "DCI Architecture". However, if you were to ADMIT that this idea is a bit overpackaging of a basic idea that's been around forever, Jim and you would have to go to your book publisher and say the book has to be scraped or rewritten? @No, we are NOT talking about what you call "compiler ojects", we are talking about runtime objects. Your examples should be based on a pluggable, event-driven "architecture", then. That's the sort of architecture most architects I know use. Your BabyIDE looks like compile-the-world procedural programming to me. |
Posts: 27 / Nickname: tblanchard / Registered: May 11, 2003 10:11 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 10:53 AM
|
I find the example given to have a contrived feeling about it. There is nothing non-OO about a funds transfer. A funds transfer is a great class to have. More importantly, it is the sort of thing likely to be persisted to a database. While I agree with the idea that the accounts take on the "roles" of source and destination, it is quite likely that any account will contain protocol to implement either role and failing this will contain minimal protocol that will allow a wrapping adaptor to make fulfilling the role straight forward and obvious.
So much for examples. OTOH, I agree that there are certain interactions that defy good OO design practice. Specifically, business rules and constraints. These rules typically capture interactions which defy all reasonable ideas of locality of reference (thank you - legislators). This is where pattern matching rules engines like ObjectiveCLIPS (http::/objectiveclips.com), JESS, CLIPS, Rete++, and similar products can save the day. |
Posts: 2 / Nickname: tbrownaw / Registered: March 26, 2009 1:17 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 5:24 AM
|
>Your design really ought to allow the details to vary, while
>keeping the semantics the same - without requiring subtyping >for different products. Sure, hopefully the later articles will have better examples than bank accounts. >The problem is, both roles and the 'actors' playing them are >derived from same ancestor, creating two parallel >inheritance hierarchies (this makes sense because a >Source_Account IS an Account and Savings_Account IS an >Account too). But a Source_Account isn't really a "thing" like an Account is, it's a way to use a "thing". So Savings_Account IS an Account (inherits from), but Source_Account is a WAY TO USE an Account (contains pointer to). |
Posts: 4 / Nickname: jhanus / Registered: March 26, 2009 8:20 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 0:05 PM
|
> But a Source_Account isn't really a "thing" like an
> Account is, it's a way to use a "thing". So > Savings_Account IS an Account (inherits from), but > Source_Account is a WAY TO USE an Account (contains > pointer to). Yes, it is a way to use an Account and nothing else. It extends specifically functionality of an Account; it is an Account plus something. I think inheritance expresses this profound relationship more clearly than embedding a pointer to the 'thing'. IMO the difference is only in the communication of intent, both ways are otherwise equally usable. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 4:29 PM
|
> > But a Source_Account isn't really a "thing" like an
> > Account is, it's a way to use a "thing". So > > Savings_Account IS an Account (inherits from), but > > Source_Account is a WAY TO USE an Account (contains > > pointer to). > > Yes, it is a way to use an Account and nothing > else. It extends specifically functionality of an > Account; it is an Account plus something. I think > inheritance expresses this profound relationship more > clearly than embedding a pointer to the 'thing'. > > IMO the difference is only in the communication of intent, > both ways are otherwise equally usable. You are missing so many subtleties here it is hard to figure out how to nail them down to you. Design is subtle. We define objects to describe a domain. They are peers. The experienced programmers here are trying to convey two things: (1) TransferSlip is your domain object, not Source_Account. Source versus destination are parameters. You gain no fidelity in your domain representation by making them first class objects. (2) The danger comes in not making your transaction interface idempotent. Even if your client and service are in the same trust boundary (which would never be the case in this example), you want some notion of a scoped guard once-and-only-once guarantee. |
Posts: 4 / Nickname: jhanus / Registered: March 26, 2009 8:20 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 29, 2009 0:16 AM
|
> (1) TransferSlip is your domain object, not
> Source_Account. Source versus destination are parameters. > You gain no fidelity in your domain representation by > y making them first class objects. That is the point you seem to be missing - they are only some parameters for you, but the DCI says they are concepts on their own within given Context. The Context forms a subdomain (albeit a small one) and the roles are its domain objects, extending actors (parameters) with features which make sense only within this Context, so the 'more basic' domain objects are not cluttered with them. > (2) The danger comes in not making your transaction > interface idempotent. I think we are discussing something else here. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 29, 2009 6:42 AM
|
>
> That is the point you seem to be missing - they are only > some parameters for you, but the DCI says they are > concepts on their own within given Context. I'm not missing the point. What do you think the responsibility of a TransferSlip is? It instantiates those contextual relationships. It also replaces Jim/Trygve's "System" actor. It becomes trivial to model a TransferSlip as a view, too. Why? B/c it's proper OO. > The Context forms a subdomain (albeit a small one) and the > roles are its domain objects, extending actors > (parameters) with features which make sense only within > this Context, so the 'more basic' domain objects are not > cluttered with them. Design is subtle. Jim/Trygve's solution greatly increases artificial consistency - that is why they refer to DCI + MVC. The small size of their solution tricks you into thinking it is good. Note: Traits are still a great idea, but still no silver bullet. > > (2) The danger comes in not making your transaction > > interface idempotent. > > I think we are discussing something else here. We're talking about state machines versus "DCI". A proper state machine has scoped guards and once-and-only-once guarantees (and a no-throw guarantee). |
Posts: 1 / Nickname: johnroth / Registered: January 8, 2005 0:52 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 31, 2009 9:21 AM
|
I'm having a significant problem seeing what's different in this approach than the approach advocated by, among others, Fowler and Cockburn(1). They advocate a separate layer between the GUI and the domain - this has been called the Application or the Process or Procedure layer by different authors.
To take the example of a funds transfer between accounts: the domain would include the various kinds of account objects as well as a FundsTransfer object. The latter object is needed because it's the transaction log, the source for the bank statement and the line entry in the bank's accounts. When the logged-in customer presses the "transfer money between accounts" button, the ATM GUI creates the ATMFundsTransfer object. The ATMFundsTransfer object then creates the domain FundsTransfer object with the amount, the source account number and the recipient account number, and it interprets the result (done or insufficient funds) back to the GUI. This matches the mental model (or at least my mental model) of how a bank transaction is normally done. John Roth (1) http://alistair.cockburn.us/Hexagonal+architecture |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 31, 2009 8:47 PM
|
@ (1) http://alistair.cockburn.us/Hexagonal+architecture
I came across this years ago on the c2 wiki, and feel the same about it today that I do now. @ They advocate a separate layer between the GUI and the domain All this stuff has a common theme. No code. No proof of clear thinking, At least drawing out a collaboration diagram, class diagram, etc. Discussing things in terms of variations of canonical GoF diagrams would help, as well. Furthermore, none of these "architectures" actually give guidance on partitioning your development team and therefore choosing how to split up the gross application structure such that the end-results of multiple teams can be seamlessly integrated. They also don't reflect real world realities, such as how services are allowed to communicate with the client. For instance, is your application request/response driven? If so, why? Are you writing a batch compiler that has to build Windows 7 source code? If so, then non-interactive fits your requirements. In the compiler marketplace, interactivity would create overhead (slowness) and would be negligent design. Are you writing a web application? If so, then how do you build an event-driven model on top of the web's inherent request/response driven model? How do you manage memory across tiers and layers? Do you just stick all memory ever requested into the HTTP Session object until the session expires? Teaching programmers to think is a scary idea, because most people lack the ability to think new thoughts... but it is more likely to solve real world problems than draping buzzword-compliant mega-patterns over your design documents. Sometimes vague ideas are good, other times they are mostly bad and irritating. In Society of Mind, Marvin Minsky has a chapter dedicated to his famous paper on programming "frames". He points out that his real contribution was that he was specific enough to give people ideas of their own, but vague enough to allow room for interpretation and creative applications. |
Posts: 4 / Nickname: jhanus / Registered: March 26, 2009 8:20 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 1:34 AM
|
I like the idea of clearly separating complex multi-object behaviour from base domain classes.
However the assignment of transferTo() to a Source Account seem arbitrary to me; it belongs to the Context instead. And why the Context could not be a simple procedure instead of an object? Like
Next, why the Source_Account could not be simply derived privately from 'dumb' Account? Like
|
Posts: 2 / Nickname: tbrownaw / Registered: March 26, 2009 1:17 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 2:37 PM
|
> Next, why the Source_Account could not be simply derived
> privately from 'dumb' Account? Like >
Derived from which kind of account? If I'm transferring money from my checking account, you'd want it derived from Checking_Account, but if I'm transferring from a savings account it should be a Savings_Account. The idea is to be able to 'attach' it to whatever kind of account happens to be appropriate, so you'll want something like
or maybe
if your Account class has the right copy semantics. |
Posts: 2 / Nickname: culana / Registered: March 24, 2009 7:51 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 0:05 AM
|
> Derived from which kind of account?
> > If I'm transferring money from my checking account, you'd > want it derived from Checking_Account, but if I'm > transferring from a savings account it should be a > Savings_Account. The idea is to be able to 'attach' it to > whatever kind of account happens to be appropriate, so > you'll want something like >
Why would you design a Source_Account, Checking_Account or Savings_Account into your design and code in the first place? Source_Account is just a role this account is playing at the time of transfer. Any account can be a source or a target, and will be at one point or another. Your account really has only one set of semantics, though the details may vary. Whether it's a Checking, Savings (or mortgage account, 30-day notice account, nostro or vostro account, etc.) are different products sold on the basis of a common set of semantics of an Account, difference being interest charged or applied, notice period, overdraft, limits, customer segment, available transfer/payment types, etc. Your design really ought to allow the details to vary, while keeping the semantics the same - without requiring subtyping for different products. |
Posts: 4 / Nickname: jhanus / Registered: March 26, 2009 8:20 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 28, 2009 3:22 AM
|
> > Derived from which kind of account?
From the core Account class, possibly just an interface, which has an identification, holds an amount of money and its balance can be changed either positively or negatively. > Source_Account is just a role this account is playing at > the time of transfer. Any account can be a source or a > target, and will be at one point or another. Right. And Savings_Account and the likes are 'real' Account-derived classes with their particular semantics, they are the 'actors' playing roles. The problem is, both roles and the 'actors' playing them are derived from same ancestor, creating two parallel inheritance hierarchies (this makes sense because a Source_Account IS an Account and Savings_Account IS an Account too). Luckily casting from Savings_Account to Source_Account is a compile-time technique and does not lose the runtime type information about who the Source_Account now really is; possible Account's virtual functions are correctly resolved as Savings_Account's one even when casted to Source_Account. |
Posts: 5 / Nickname: trygver / Registered: September 7, 2003 9:58 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 9:25 AM
|
There has been some comments of the type: "Couldn't this code have been written differently/better". The answer is almost always yes; the Bank example is designed to exemplify important DCI concepts in the simplest imaginable program, not to teach programming style.
Some writers have asked for more complete and detailed examples. I have written an IDE for DCI-based programming in Squeak (a dialect of Smalltalk) and used it to code more examples. The first, relatively complete documentation of this work was published as a program and report 6 months ago. Much has happened since then, and I am close to releasig a new edition. The updated document includes three examples with commented code. Rather than wait for the report to get to a state where I can show it to other people, I will be posting preprints of some of the chapters. The first chapter preprint documents a working Bank transfer program. You find it at http://heim.ifi.uio.no/~trygver/2009/bb5bank.pdf I have also posted a description of the programming environment BabyIDE1: http://heim.ifi.uio.no/~trygver/2009/babyide1.pdf My BabyIDE/DCI home page has been updated: http://heim.ifi.uio.no/~trygver/themes/babyide/babyide-index.html I hope these posts answer some of the outstanding questions. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 31, 2009 9:06 PM
|
@Trygve
> The first chapter preprint documents a working Bank > transfer program. You find it at > http://heim.ifi.uio.no/~trygver/2009/bb5bank.pdf Quote: @The Context bind roles to objects upon instantiation so that TransferMoneySource has been bound to the appropriate account when the execution gets to this point. This is totally wrong. You are doing compile-the-world procedural programming. You're also strongly typing it to give the impression it's rock-solid design. Rejoice, though. I'm sure there are still some Java programmers who use EJBs who can't tell the difference. With a TransferSlip (as I've stated many times here as the right approach), you let the user determine the execution. There is no "this point" guarantee. In fact, when you display a TransferSlip on screen, the source has yet to even be instantiated. This gives you a totally different look at the world, and it's called OO. |
Posts: 1 / Nickname: niclash / Registered: June 1, 2007 3:55 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 6, 2009 10:23 PM
|
Bill, James and Tryggve.
> The Qi4J environment (Richard Öberg and Steen Lehmann) > is pushing forward the ability to express traits in a > Java environment. I would appreciate if credit is not given incorrectly. Steen is an all-time good guy, but his involvement in Qi4j is non-existent at best. Rickard and myself are the founders, and there is a team of ~5-10 people who work on the codebase to varying degree. |
Posts: 1 / Nickname: sadache / Registered: October 9, 2007 8:03 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
June 21, 2009 3:29 PM
|
Posted a real world example of DCI with Scala on
http://sadekdrobi.com/2009/06/10/dci-in-real-world-domain-context-and-interaction-with-scala-in-a-real-world-project It is open to any improvements, suggesions or critics. |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
November 26, 2009 10:08 AM
|
I am not sure that the DCI Architecture is the new vision of OOP. As I pointed out to Trygve Reenskaug in the personal e-mail, MVC is the concept that was used not only for OOP, but in non-object oriented environments and languages. It seems to me that DCI is just a sort of renaming things that were intriduced by the professor 3 decades ago. It resembles the Microsoft practice of inventing new terms for the same subject. I do not think that DCI can simplify any development efforts or drive to a better framework or application.
|
Posts: 98 / Nickname: achilleas / Registered: February 3, 2005 2:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 23, 2009 1:36 AM
|
If they need such a long article to explain what the DCI architecture is, then I am sure it will not work in reality.
Things that truly work are truly simple. |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 2:18 PM
|
> If they need such a long article to explain what the DCI
> architecture is, then I am sure it will not work in > reality. > > Things that truly work are truly simple. It's simple once you drop most things you learned in your college OO education. I frequently give a one-hour talk on this at conferences. Most of the communities that formed to write code around their own programming languages were launched from that one-hour talk (the hour includes Q&A time). This paper is more thorough and includes the historical exposition and a more complete rationale. Far too many current misconceptions were launched from pop articles on pop web sites and pop magazines. We're aiming at professionals who want to advance, or at least start, their thinking. Such thinking probably requires more of an investment in time than most pop site readers are willing to put in. I'm happy to reach the few willing to make that investment -- including going back and trying to develop the examples for themselves. As mentioned above, there are many examples in the book manuscript --but, given your post, I'm not sure that book reading is for you -- unless it's a comic book. |
Posts: 98 / Nickname: achilleas / Registered: February 3, 2005 2:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 6:06 AM
|
> > If they need such a long article to explain what the
> DCI > > architecture is, then I am sure it will not work in > > reality. > > > > Things that truly work are truly simple. > > It's simple once you drop most things you learned in your > college OO education. I frequently give a one-hour talk on > this at conferences. Most of the communities that formed > to write code around their own programming languages were > launched from that one-hour talk (the hour includes Q&A > time). > > This paper is more thorough and includes the historical > exposition and a more complete rationale. Far too many > current misconceptions were launched from pop articles on > pop web sites and pop magazines. We're aiming at > professionals who want to advance, or at least start, > their thinking. Such thinking probably requires more of an > investment in time than most pop site readers are willing > to put in. I'm happy to reach the few willing to make that > investment -- including going back and trying to develop > the examples for themselves. > > As mentioned above, there are many examples in the book > manuscript --but, given your post, I'm not sure that book > reading is for you -- unless it's a comic book. Thank you. By your insult I can understand that DCI is another set of those things that do not work in practice. Here is a challenge: explain DCI in one short paragraph. Unless you can do that, DCI has no chance in the real world. By the way, isn't the Internet a wonderful place where any stranger can insult you without any consequences? :-) |
Posts: 5 / Nickname: trygver / Registered: September 7, 2003 9:58 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 10:29 AM
|
Hi Achilleas Margaritis,
@Thank you. By your insult I can understand that DCI is @another set of those things that do not work in practice. Insults can be entertaining, but they are rarely productive. I fail to see the how insults can affect the practicability of anything, one way or another. @Here is a challenge: explain DCI in one short paragraph. @Unless you can do that, DCI has no chance in the real @world. You are probably right due the short attention span of many experts. (Another unproductive insult. I find it easier to insult than to think and say something with some substance to it). Seriously: The prolific 19th century Danish philosopher and theologian Søren Kierkegaard once said something like this: "if you want to teach somebody something, you go to where they are and walk with them from there." (Quoted from memory). I have always taken this as challenge to myself as a speaker and a writer. In this case Jim and I only knew that our readers would come from many different specialities, have many different backgrounds and priorities, and come from many different cultures. Communication between people requires a common vocabulary. It is easy to describe DCI in one short paragraph assuming that our readers shared our vocabulary. For example: "DCI is about separating the code for system state from the code for system behavior". Very tabloid and doesn't say much. I expect the sentence can lead to many more questions than it answers. We clearly do not have a shared vocabulary. If we had, the discussion would have been very different. Hence many more words than a single paragraph are needed. Success is only possible if both writer and reader are prepared to expend the time and energy required to establish such a common vocabulary. "Here is a final challenge: explain Java in one short paragraph to a programmer who has never heard of Java before. Unless you can do that, Java has no chance in the real world." Hm. The shortest explanation I have heard is "metadon for C++ programmers". |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 26, 2009 1:12 PM
|
@We clearly do not have a shared vocabulary.
We do, and it is called CODE! Describe the problem with existing approaches by showing how unreadable their code is. You don't unify a vast audience with a strawman. |
Posts: 98 / Nickname: achilleas / Registered: February 3, 2005 2:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 4:58 AM
|
> Hi Achilleas Margaritis,
> > @Thank you. By your insult I can understand that DCI is > @another set of those things that do not work in > practice. > > Insults can be entertaining, but they are rarely > productive. I fail to see the how insults can affect the > practicability of anything, one way or another. > > @Here is a challenge: explain DCI in one short paragraph. > @Unless you can do that, DCI has no chance in the real > @world. > > You are probably right due the short attention span of > many experts. (Another unproductive insult. I find it > easier to insult than to think and say something with some > substance to it). > > Seriously: The prolific 19th century Danish philosopher > and theologian Søren Kierkegaard once said something like > this: "if you want to teach somebody something, you go to > where they are and walk with them from there." (Quoted > from memory). I have always taken this as challenge to > myself as a speaker and a writer. In this case Jim and I > only knew that our readers would come from many different > specialities, have many different backgrounds and > priorities, and come from many different cultures. > > Communication between people requires a common vocabulary. > It is easy to describe DCI in one short paragraph assuming > that our readers shared our vocabulary. For example: "DCI > is about separating the code for system state from the > code for system behavior". Very tabloid and doesn't say > much. I expect the sentence can lead to many more > questions than it answers. I did not ask for a short explanation, I asked for the simplest explanation there is. > > We clearly do not have a shared vocabulary. If we had, the > discussion would have been very different. Hence many more > words than a single paragraph are needed. Success is only > possible if both writer and reader are prepared to expend > the time and energy required to establish such a common > vocabulary. I disagree. If one truly understands something, he/she can describe it in a simple way. > > "Here is a final challenge: explain Java in one short > paragraph to a programmer who has never heard of Java > before. Unless you can do that, Java has no chance in the > real world." Hm. The shortest explanation I have heard is > "metadon for C++ programmers". You confuse 'simplest' with 'shortest'. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 5:38 AM
|
@Achilleas
@You confuse 'simplest' with 'shortest'. It's cool how they're wasting their breath responding to "insults" but "valid points" are not even so much as acknowledged. They don't just confuse "simplest" with "shortest". They confuse "logic" with "politics". Somehow, they're under the impression they can break people into believing there is a radical new idea here. Hey, I have a group of programmers I need to present an idea to about how they write their code. I'm going to use almost no code to do it and meanwhile keep berating them for not understanding the user's mental model. |
Posts: 8 / Nickname: alexstojan / Registered: June 20, 2005 0:51 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 8:07 AM
|
> @Achilleas
> @You confuse 'simplest' with 'shortest'. > > It's cool how they're wasting their breath responding to > "insults" but "valid points" are not even so much as > acknowledged. > > They don't just confuse "simplest" with "shortest". They > confuse "logic" with "politics". Somehow, they're under > the impression they can break people into believing there > is a radical new idea here. > > Hey, I have a group of programmers I need to > present an idea to about how they write their code. I'm > going to use almost no code to do it and meanwhile keep > berating them for not understanding the user's mental > model. I've got one suggestion for you: talk less and listen more! |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 11:50 AM
|
>
> I've got one suggestion for you: talk less and listen more! My suggestion is: Always demand the best code. What should I be listening to? Can you point me to something I clearly seem to be missing? |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
November 28, 2009 5:16 AM
|
> > If they need such a long article to explain what the
> DCI > > architecture is, then I am sure it will not work in > > reality. > > > > Things that truly work are truly simple. > > It's simple once you drop most things you learned in your > college OO education. I frequently give a one-hour talk on > this at conferences. Most of the communities that formed > to write code around their own programming languages were > launched from that one-hour talk (the hour includes Q&A > time). > > This paper is more thorough and includes the historical > exposition and a more complete rationale. Far too many > current misconceptions were launched from pop articles on > pop web sites and pop magazines. We're aiming at > professionals who want to advance, or at least start, > their thinking. Such thinking probably requires more of an > investment in time than most pop site readers are willing > to put in. I'm happy to reach the few willing to make that > investment -- including going back and trying to develop > the examples for themselves. > > As mentioned above, there are many examples in the book > manuscript --but, given your post, I'm not sure that book > reading is for you -- unless it's a comic book. I just wanted to point out that the MVC description - Figure 1 of the article and around it is not the original MVC which separates the View and the Controller portions which do not interact directly as it is shown on Figure 1. Please check with the original (30 year old) work of the professor Reenskaug. The picture an what you describe around it looks more like MVP and because of that all the critics around is not relevant to MVC. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 7:00 PM
|
@MVC is about people and their mental models—not the Observer pattern
This is the most pretentious, long-winded, non-scientific article written by academics imaginable. "Hey, you foolish practitioners, you are ignoring the user." First off, their real world example is AWFUL and they're discredited on that basis alone. And I quote: @2. System displays valid accounts WHAT? Are you seriously going to put a System class in your problem domain analysis classes? That will adversely affect the gross application structure, which is SUPPOSED to directly reflect the problem domain. You are sharing server-side concerns with the client. Why stress your network that much? This example basically mimics many awful ATM controller software examples in various books alleging to teach OOA. I will stick with Allen Holub's brilliant criticism of MVC: It is fundamentally not OO, because of Controllers. Object-oriented programs should RENDER THEMSELVES. Objects should be able to render themselves. Not being able to meet this constraint is an obvious code smell that you should clean up. This code smell is typified by frameworks like Struts. This is actually why understanding how real-time OO engineers apply OO can be so helpful to enterprise programmers. Once you start thinking in real-time terms, chatty protocols become obviously unacceptable. The fact they deal with subsequences at the application protocol level is an analysis smell: You're coding low-level details at the highest layer of your architecture, which will make it impossible to stabilize design, forcing recompilation. Today, most MVC approaches use IoC containers and pluggable architectures to try to skip as much recompilation as possible, but mentally they're still recompiling. My designs are pretty stable, although I refuse to call them MVC, because of the use of Controllers. My objects render themselves - they don't expose implementation details simply so that a delegate can render for them. And you know what? I rarely recompile these days. The much bigger question is how to build OO systems based on REACTIVE MODELS. Reactivity gives you a direct mental model for any user. |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 4:31 AM
|
> @2. System displays valid accounts
> > WHAT? Are you seriously going to put a System class in > your problem domain analysis classes? Yes. A Use Case is a contract between an end user and a system under construction. Too many programmers take this beyond analysis into design. The Use Case ends up being pseudo-code that over-constrains the ordering of processing as well as other design choices. A Use Case should focus on "what," not "how." Are you seriously going to put something other than the system in your problem domain analysis? By the way, I have no idea what a "problem domain analysis class is." Can you be more precise? |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 7:33 AM
|
@By the way, I have no idea what a "problem domain analysis class is." Can you be more precise?
Thanks, a common vocabulary is important. An analysis class captures some indivisible aspect of the problem domain. Great examples of analysis classes are in Fowler's book Analysis Patterns. @Yes. A Use Case is a contract between an end user and a system under construction. Too many programmers take this beyond analysis into design. The Use Case ends up being pseudo-code that over-constrains the ordering of processing as well as other design choices. A Use Case should focus on "what," not "how." The benefit of a use case is it is something both the user and engineers can understand and agree upon. The benefit of a framework is it is something you can use regardless of small details captured in use cases. In that sense, at some point you need to talk about making sausage-things the user doesn't care about. If you get your gross application structure wrong, then there is no way you are going to stabilize design. A designer-developer facade is also focused on "what", but leaves out implementation details such as perhaps using "nerd-centric" state machines. The classic example of this is the Browser. The idea that you have a client responsible for negotiating formats with a server and also responsible for knowing how to render those formats is anti-OO. Actually, this is a point Alan Kay makes very clear in his 1997 OOPSLA speech The Computer Revolution Hasn't Happened Yet. @Are you seriously going to put something other than the system in your problem domain analysis? Well, that's what I do now. I don't say "The system displays valid accounts", because a System object is way too vague to assign responsibilities too? Moreover, intuitively, it has a "God class" feeling to it. I am suggesting that you are backing yourself into false premises with statements like these in your article: @Unfortunately, object orientation hasn't fared so well to capture how we reason about doing. There is no obvious "place" for interactions to live, either on the GUI or in the code. There are exceptions to this rule, particularly for simple actions that involve only a single object. In practice, you are very, very, very correct in describing how most people write their OO code. But they're also sharing too many implementation details, which is obviously counter to OO. If you want to tell me that traits are a way to provide syntax so developers STOP their bad practices and finally practice the 00 oaths, then that is different. You and I both know compiler syntax features are important, because we can't expect the average developer to be a compiler writer and invent great DSLs -- it's been tried in the past and doesn't work. I fully understood your point, here, and it is a really hard one to explain -- which is why I'm pushing you so hard. However, there is absolutely a place for interactions to live. I'll give you examples of things I see as OO anti-patterns that may better illustrate your point. Presentation-Abstraction-Control is an architectural pattern like DCI and intended to address issues such as multi-object interaction. However, the pattern is ultimately ad-hoc case statements (that is what the Control object does at every layer). Yet, it is pitched as "MVC for multi-object interaction". Another thing you can consider pedagogically is borrowing examples from your competitors. You shoot down state machines as being "nerd-centric", so hopefully you are well-read on the classical examples in FSM literature. However, I'll point them out to you: Ian Horrocks' book Constructing the User Interface presents several examples, beginning with non-OO VB code representing the interactions for a calculator. He then discusses how a HSM can clarify requirements and eliminate bugs. This example was copied by Miro Samek in his two Statecharts books, and he calls it The Ultimate Hook pattern. http://www.state-machine.com/devzone/Pattern_UltimateHook.pdf Something similar to role-based modeling is Karl Lieberherr's Demeter Tools. All you have to do is write propagation directives targeted at what a Scala developer might call a "case class". In addition, because Karl uses a parts-centered object model that is easier to type-check and express parts-invariants, it is possible to specify business rules (albeit not so clearly, but that is an artifact of not taking the idea to its logical conclusion). |
Posts: 40 / Nickname: vincent / Registered: November 13, 2002 7:25 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 23, 2009 3:19 AM
|
> Ian Horrocks' book
> Constructing the User Interface presents several > examples, beginning with non-OO VB code representing the > interactions for a calculator. He then discusses how a > HSM can clarify requirements and eliminate bugs. I've just had a quick look on amazon.co.uk for that book; prices range from £112 to £248. Now, if only I could get someone to buy it for me... |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 23, 2009 6:00 AM
|
I don't recommend copying Horrocks' designs. He hardcodes in entry/exit guards and actions. This is a brittle design.
The nice thing about the Silverlight approach is that you can store the object model in a "stylesheet". Unfortunately, because it doesn't use a functional reactive programming model, it can't merely recompute the differences. There is also two other flaws with the Silverlight model, but on the whole I like it much better than other models. You can always e-mail the author to ask the publisher if he can provide a copy of the book online for free now that it is out-of-print. Harel did this for his Statemate book. http://www.wisdom.weizmann.ac.il/~dharel/reactive_systems.html |
Posts: 2 / Nickname: rbokel / Registered: February 26, 2009 6:29 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 31, 2009 1:55 AM
|
Can we remove all the dynamic aspects and start with a static implementation in plain Java. From there we can explore the advantage and possibilities of more dynamic approaches.
|
Posts: 8 / Nickname: sebastiank / Registered: September 19, 2005 2:05 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 1, 2009 9:09 AM
|
> Can we remove all the dynamic aspects and start with a
> static implementation in plain Java. From there we can > explore the advantage and possibilities of more dynamic > approaches. I have been busy so it took a while. Sorry. In my latest post there are two versions of the account example in Java: One without traits and one with traits. The examples are taken from Jim Copliens book draft. http://www.jroller.com/sebastianKuebeck/entry/object_oriented_programming_2_0 To Trygve Reenskaug and Jim Coplien: Keep up the great work! No matter what some comments babble. You cannot please everyone :-) |
Posts: 2 / Nickname: rbokel / Registered: February 26, 2009 6:29 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 1, 2009 2:11 PM
|
Thanks Sebastian. Very helpful.
|
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 1, 2009 10:16 AM
|
@No matter what some comments babble. You cannot please everyone :-)
It's not about pleasing. It is about not using strawman's to say OO doesn't work. http://www.jroller.com/sebastianKuebeck/entry/object_oriented_programming_2_0 @As you can see, DCI helps to increase cohesion in object models while remaining it understandable. It introduces additional flexibility and solves problems that would cause nasty workarounds otherwise. Judging by this example, it seems you choose to ignore (or simply don't understand) what the debate is even about. DESCRIBE THE PROBLEM YOU CLAIM CAUSES "NASTY WORKAROUNDS". Back up your claim. Show me the pain I supposedly experience today, and why I should convert to your religion. Bootstrap your example with a GUI. Connect DCI to MVC. Let the fun begin. |
Posts: 8 / Nickname: sebastiank / Registered: September 19, 2005 2:05 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 2, 2009 2:59 AM
|
> It's not about pleasing. It is about not using strawman's to say OO doesn't work.
On the contrary. Programming paradigms are exchangeable by definition. There is no right or wrong as you can choose any paradigm you like to get working software. It is an inherently irrational choice. So if you take "OO fails to capture behavior" literally and out of the context, you are right that this claim is exaggerated. About my claim: > It introduces additional flexibility and solves problems that would cause nasty workarounds otherwise. You are right. You can find good solutions (using pure OOP or whatever) for that problem without using DCI. |
Posts: 5 / Nickname: trygver / Registered: September 7, 2003 9:58 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 4, 2009 6:36 AM
|
I have put new section preprint on my DCI page for your enjoyment. The section describes an activity planning program that combines DCI and MVC. It is still a toy program, but closer to reality than previous examples.
I have implemened two versions; one with DCI and one without. The two versions have been made as similar as possible to expose what DCI does to a program. The answer is that it organizes the code differently so that the programmer's mental model is different. The article is at http://heim.ifi.uio.no/~trygver/2009/bb4plan.pdf my DCI home page is at http://heim.ifi.uio.no/~trygver/themes/babyide/babyide-index.html |
Posts: 13 / Nickname: schluehk / Registered: January 20, 2005 5:46 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 5, 2009 0:28 AM
|
> On the contrary. Programming paradigms are exchangeable by
> definition. There is no right or wrong as you can choose > any paradigm you like to get working software. It is an > inherently irrational choice. Yep. It's almost like the term "paradigm" was originally used: to mark different consistent but incommensurable views of the world. It was used to criticize the idea of linear progress and not few philosophers of science attempted to demonstrate that paradigms are a myth and everything worthwhile can be subsumed in a rational reconstructions of history. All those voices have become silent and I guess that's mostly because no one seeks for alternative worlds and world views anymore. In this particular situation the term "paradigm" has simply be subsumed by progress: there must be a best paradigm and usually the latest one is the best ;) |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 5, 2009 9:51 PM
|
I will defer to Thomas Kuhn on the nature of scientific revolutions, and instead stick to what I know best.
In my experience, application design has changed over the years, and it can basically be dumbed down into the following trends at the toolkit level: 1) Making the model more view-friendly 2) Making the view more model-friendly The biggest advancement has been data binding. A big question, however, is how to connect the two View and Model while simultaneously allowing for rich interaction. The easiest solutions are to cheat: Put an IView factory method on the Model object(s) and have it display the view. However, this not only poorly captures rich interaction, it also effectively assigns creation of View objects to developers rather than designers. Also, unless the factory method is determining its object builder instructions from an external source, then it is inherently a compile-the-world application. I'm not convinced this approach -- what I call "the Microsoft Office model of application development" -- is right for everyone. Office might be the bestselling software in the world, but its unique. Most software has a totally different set of UI/UX assumptions with regard to deployment. The underlying code may use the same patterns -- i.e., (Guarded) Command patterns for actions -- but the big differences are in deployment and decisions on what gets dynamically injected at runtime. In a big way, that is what I keep harping on. In Trygve's new example. he says the activity network is hard coded and brushes that off. However, to refactor his code to use mobile activity networks, he'd also have to re-jigger his controller object. "Paradigm" or not, it's compile-the-world metaphors and not driving hard at addressing the challenge of loose coupling plus readability. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 1, 2009 11:13 AM
|
Just to zero this in... in case people still don't get it...
Jim said in his article: @The MVC framework makes it possible for the user to reason about what the system is: the thinking part of the user cognitive model. But there is little in object orientation, and really nothing in MVC, that helps the developer capture doing in the code. Jim says MVC is a flawed architecture. I agree. Where we differ is on this myth that you should add DCI on top of MVC to fix the problem. Jim likes the idea of using his DCI to patch MVC. I don't. Instead, I prefer to create truly object-oriented user interfaces. But why do I think Jim is heading in the wrong direction? Is it merely accidental complexity at the architecture level? NO! The complexity actually boils down to his object model codified in his use cases. His example gave the following use case: 1. Account holder chooses to transfer money from one account to another 2. System displays valid accounts 3. User selects Source Account 4. System displays remaining valid accounts 5. Account holder selects Destination Account 6. System requests amount 7. Account holder inputs amount 8. Move Transferred Money and Do Accounting The entity in that use case that clearly doesn't belong is the System object. In proper OO, that is a TransferSlip (and for another use case it is WithdrawalSlip, another use case it is DepositSlip). The TransferSlip replaces steps 2, 4 and 6; it replaces the "System display" actor. Are any of you disagreeing with my decision to do this? If so, why do you think it hurts the clarity of the code? I really want to know. |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
November 28, 2009 5:44 AM
|
@Jim says MVC is a flawed architecture. I agree.
If you think that MVC is flawed, it looks like you did not understand the basics. MVC is the way the mother nature built humans. It is the only way humans (and other living objects) actually interact with each other and the environment. In the psychology it is called beavioral stereotypes. Trying to replace one stereotype (fundamental MVC) with another one (less fundamental DCI) makes very little sense. The only implication will be the fact that those who now advertise MVC as the foundation of their frameworks will replace MVC with DCI in their adds (if DCI gets accepted; but it took over 15 years for MVC to get accepted; so it does not seem that DCi will get anywhere soon; probably, besides NetBeans where one of its architects already announced that MVC is obsolete). |
Posts: 2 / Nickname: trefork / Registered: April 27, 2009 4:11 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 27, 2009 9:17 AM
|
John Zabrozki wrote:
> My objects render themselves and > Instead, I prefer > to create truly object-oriented user interfaces. John, I'm very interested in your approach. Would you care to elaborate on this? E.g. I would like to know if your domain classes are tied to a given presentation model, or if you can reuse your domain model with both a Swing and HTML GUI? Is your methodology well-defined and published, or is it based on years of experience? If the former, could you provide links/titles/etc? |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
May 11, 2009 8:03 AM
|
It is based on years of experience and reading.
It is not based on any of Fowler's patterns. Instead, it is based on hypermedia concepts as well as other theories, such as hierarchical state machines, behavior trees (used in game programming), agent-oriented programming, feature-oriented programming, adaptive object-oriented programming, aspect-oriented programming, theories from information science such as Codd's relational model and Darwen/Date's relational model, master data management, etc. The biggest value in all these theories is that they establish proven reasons for why I write a particular chunk of code. Every line of code should have a purpose. I don't believe in calling something "architecture" if it's mainly a bunch of shunts and shims holding things in place. For hypermedia, I was always interested in the work of PJ Brown (GUIDE), Ted Nelson (Xanadu), Douglas Englebart (the mouse, among other hypermedia contributions), Roy Fielding (REST) and EJ Whitehead (WebDAV). There was also in the '90s a bunch of methodologies for blending Object-orientation with Hypermedia, although I feel the papers were somewhat hard to read without trying to prototype the ideas in code while reading the paper. Also, Wikipedia taught me a fair amount about fancy caching of hypermedia. Wikipedia is the world's largest "composite/structured application". For object-oriented user interfaces, I first heard about these my freshman year in college when Allen Holub published a series of JavaWorld articles on them, and I later bought the book <em>Naked Objects</em> by Richard Pawson and Robert Matthews. Neither of these resources are particularly good, though. Why? (1) Pawson sounds too much like a CTO giving a high-level overview, and he never really discusses core architectural concepts, despite bashing others (2) Holub focuses too much on simply eliminating "Getters", and doesn't go into much detail on application structuring. In fact, his book <em>Holub on Patterns</em> has some rather non-exemplary code. I suspect part of the problem is the weight of Swing; it's simply too hard to do anything radically OO in Swing. Just look at the Naked Objects Framework created by Pawson to see how limiting Swing is. Don't just look at the screenshots; look at the underlying code and extensibility points. Swing simply requires solving too many problems at the wrong level of abstraction to ever build a OOHUI (Object-Oriented Hypermedia User Interface) with it. Thankfully, Sun is starting to zero out Swing's budget. For state machines, there is a long list of books on this subject. They all take different approaches. The real value here is in a model for REST's "Hypermedia as the engine of application state" principle. Most people don't get this principle whatsoever, and even joke about it by referring to their incorrect usage of REST as "Lazy REST". I don't publish. > E.g. I would like to know if your domain classes are tied > to a given presentation model, Why would I do something silly like that. The moment you have to vary the user interface, such as by user role to restrict permissions, your presentation model becomes needlessly complicated. For what it is worth, I don't like Fowler's explanations of GUI Architecture. He doesn't really do a good job explaining the consequences of going down a particular route. However, bear in mind he's not committing serious time to these articles, either. My basic observation though is that Martin simply breeds trust, and it sometimes leads to people using his patterns for the sake of using one of his patterns, because there is a feeling you'd look foolish if you didn't. I personally reject three layered architectures. They make no sense whatsoever. I also reject traditional n-tier SOA architectures, because they are not event-driven but simply services-driven. I suspect in 10 years time the industry will finally transition to better practices; things like Enterprise Message Bus technology is finally maturing in the proprietary sector, which means FLOSS will be soon to catch-up. The trail has been blazed. > or if you can reuse your > domain model with both a Swing and HTML GUI? I strongly believe in Model-Driven Architecture. Currently, a domain model maps to two UI platforms. However, that's not challenging. What has proved technologically challenging is creating an infrastructure for consistent styling, but our customers don't seem to care. They just want fewer mouse clicks and clean UIs. There are things like Mesh for skinning Struts applications, but they are Web-only. Currently, we use a rather monolithic cascading stylesheet language subset, and have our own CSS-subset interpreter on the Desktop. However, the level of styling is sort of limited compared to the sexiness you could get out of not using OO MDA, and just writing an Ext.js application directly. As always, MDA is not cheap up front. Just look at how much of a struggle it is for Jim van Dam on the Eclipse RCP project to move to model-driven architecture. Not only is it hard for him, but it will likely be hard for others as well. He is a UML weenie, so in order to use his MDA approach you are locked into UML for your models. I'm not bashing UML, only pointing out that Jim's work is for "Fortune 100" Eclipse users. Despite not being cheap, effectively modeling your architecture will simplify every decision you make after the fact. |
Posts: 2 / Nickname: trefork / Registered: April 27, 2009 4:11 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
May 13, 2009 0:35 PM
|
> such as hierarchical state machines, behavior trees (used
How do you do state machines? Framework supported or ad-hoc coded? > > E.g. I would like to know if your domain classes are > tied > > to a given presentation model, > > Why would I do something silly like that. The moment you > have to vary the user interface, such as by user role to > restrict permissions, your presentation model becomes > needlessly complicated. How then do they render themselves while at the same time not exposing their innards to a potential "presentation layer"? > > or if you can reuse your > > domain model with both a Swing and HTML GUI? > > I strongly believe in Model-Driven Architecture. > Currently, a domain model maps to two UI platforms. Mapped, but not tied? Could you elaborate on the difference. > Despite not being cheap, effectively modeling your > architecture will simplify every decision you make after > the fact. Couldn't agree more, MDA or not. |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
November 28, 2009 5:55 AM
|
@To John,
It looks like you missed the major point from the 'Naked Objects'. It is the idea to avoid spending lengthy hours on programming GUIs, but use the framework or one application that will display them for you in a standardized way. You may not like this standardized view, but you save your time and budget and avoid programming event listeners which you would do and probably continue to do (if you are involved with GUI implementation). Fortunately, Java and C# run-times allow the introspection for that. |
Posts: 1 / Nickname: rpr / Registered: November 29, 2009 3:28 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
November 29, 2009 0:46 PM
|
The OO Problem
From a high level DCI et al is an effort to "fix" what is broken in the OO model from an OO perspective. The brokenness manifests itself with standard OO Analysis and Design. Parse the domain into classes, assign responsibilities to said classes ,and execute Use Cases via collaboration of runtime object instances of said classes. The failure is the inability to pigeon-hole a clear unit of capability/responsibility solely to a single class. It all becomes a forced, shoe horning of capabilities into classes, the opposite, a thin scattering across classes losing all cohesiveness. OO says you _have_ to "put it" somewhere. And your told if you can't figure out where to put it, you're OO chops are just not up to snuff or your OO model is flawed. Throw it out and start over until you can assign each capability/responsibility to its appropriate OO owner. The fact that this is not possible is ignored by OO. One camp says the problem is your classes are just too domain anemic, that Order class needs to be beefed up for example. But it becomes a blackhole. More capability, entails and entrains more capability. The Order class soon becomes the Ordering class, a massive God Object that IS the program. At which point the other camp chimes in no, no, no, "do one thing and one thing only" in your classes. Then all your devouring blackhole God objects go Nova, exploding into a scintilla of ever more anaemic single purpose classes., devolving towards simple state wrappers and manipulators, increasingly orphaning the "do stuff" aspects of your program with nowhere to "put" it. As all the Noun classes rapidly devolve into simple Data Encapsulators a myriad of -e/or classes explode onto the scene to stitch things together. These are the artificial Class constructs sprung straight from the forehead to act as places to attach all the orphaned "do stuff" code. The Transact-or, the Book-er, the Price-r, the Submit-or, the ... Do'er. But it's all wrong, wrong, wrong, it ain't OO, and you HAVE to be OO. So you take all those zillions of teeny tiny classes do'er and state wrappers that lack any sort of coherence and start merging and combining things back into Nouns classes. Carefully assigning capabilities strictly and solely to each one. Blackholes God classes re-emerge sucking in responsibilities, demanding attachment, until ... While BigBang followed by Collapse and re-Bang in an endless cycle may be a fine way to run a universe, it is not necessarily so for running the design of a program. Fixing OO Can't Be Done Via OO I think the "ideas" to fix OO are and have been out there for quite awhile. The failure is the repeated attempts to apply the fixes in the context of OO in tortured OO terms. A entirely new and different vocabulary is necessary. Instead of trying to stretch OO concept semantics to "bend" in new concepts why not just properly label the new concepts and retain OO terms and concepts for OO. For example, in DCI, objects tend to degenerate into "dumb" simplistic state encapsulators barely smart enough to manipulate their enclosed state. The canonical DCI Account classes encapsulate an amount value and token manipulator methods of this value. Yet is is still discussed as an OO class with OO instances. But it's not. Its no longer a robust domain driven Account stuffed with transactive capability for example. Its just a state wrapper and manipulator. Its closer to a simple structure with associated procedures with an implicit self parameter than full-blown OO object. The point of all the above is to say that fixing the conceptual flaws of OO-ness by constraining solutions to be OO-centric in nature does not appear to be working very well. The solutions appear well known but fail to translate and for the life of me I don't understand why the translation is necessary! OO must be subsumed by a new solution; it cannot be the solution, only an aspect of it. To be clear I certainly don't know enough to state the solution. What I am saying is it appears some really smart people appear to know the answers but fail to materialize them in translation. The self imposed OO-only constraints completely obstuficate what were originally rather straight forward solutions. Attempts to demonstrate new multiparadigm higher level design approaches that sit above OO design become a morass with repeated attempts to reifiy the solutions within OO boundaries. Watch for example the Account with Funds Transfer problem degenerate into exercises in tortured C++ templates or pushing anaemic, kindergarten Java to do things via ever more clever contortions. What Must Be Done Stop trying to shoehorn multiparadigm solutions within a legacy context OO paradigm context. Stop defining solution paradigms a top of ancient languages such as C++, Java or SmallTalk. Total waste of time. They cannot be fixed. Enough with exotic, boilerplate, effusive "Patterns" over these substrates. We need a better substrate. OO must be subsumed or at minimum become a peer paradigm NOT the central tenant. Why continue to discuss a new paradigm such as DCI in OO terms within an OO constrained language, when a priori your objects are not objects, often just dumb data manipulators, and just-in-time role casting is necessary? The answer is obviously a multi-paradigm / hybrid one. I'd go as far to claim at a minimum one which combines Functional with OO. One must start with a multi paradigm / hybrid language to properly demonstrate new design and implementation solutions. Lets use Scala for the rest of the discussion. Why? Its multiparadigm (OO, Functional, Actor, Pattern, Algebraic) in design AND clean enough that there is a good chance missing paradigms could be added cleanly as smooth extensions of the language or properly as libraries. For the hell of, imagine if the current semantics of Scala was _not_ modified one iota, however the following term syntax aliasing was allowed.
To get a gist of the impact of these simple term substitutions let's examine a couple of them. Module over object encourages people to "think" conceptually different. Its a gathering spot for those procedural, algorithmic things. It is a place where "functional" things can be defined cleanly. These is no dissonance in concieving the below in a "module". But it's a mental hurdle to view it both as a singleton "object", and as the natural container for such constructs.
It is the proper place in Scala land of course, but it seems forced. Of course the Scala folks know this. So why Object and not Module. Because we keep trying to defined new concepts as tortured OO concepts otherwise the Java folks won't grok it. People don't know what a Module is anymore therefore the most intuitive way to add modules conceptually is as singleton object. Aside: Imagine, giving a talk to COBOL, VB, PL1, RPG, PLSQL and Java developers, its the folks with only the "modern OO" language experience you have to slow down for to explain what modules, procedures and functions are. Ironic. Object implies Class instance and hence a sort of domain mapping (for me) and the reification of some domain "thing". But it's simply a cohesive grouping of procedural code, functions and algorithms that "do stuff". Where is the "object" I ask you? Sure one can hand wave and claim scala Object is isomorphic to a Module, but damn it it's a module first and a clever means singleton object construction second. Class -> Struct. (SML structure, not C) Again the idea here is to move away from the OO relentless domain mapping of objects and things and allow one to think in a guilt free manner of constructions whose primary purpose is to encapsulate and manipulate state without OO burden. I want to be guilt free to think of these things as simply encapsulated data, with associated functions with an implicit self parameter without a receiving a citation from the OO police for an Anaemic Object violation. By simply aliasing 5 or 6 key terms in the Scala language, without changing any of the semantics of the language, one gets a "whole" new language in the sense that the "way" a single individual would write a program to solve a problem would radically shift. Same problem, same programmer, same language. Alias five terms and one would gets a more functional code base with appropriate and prevalent state encapsulation. Same semantics just different labelling, say Structures/Instances instead of Classes/Objects. Leave the current syntax labelling in place one would get a OO centric code base with modest migration of procedure code and algo out of Classes. It all depends on how much the developer can soar above the OOness of the Scala's bias to use non-OO paradigm constructions with peer OO constructions to solve the problem. One variation of Scala supports DCI and other solutions with less dissonance, the other implies a straining to achieve DCI, a continued uphill struggle to break free beyond just OO in the solution space. In less capable languages such as C++ or Java the strain becomes an all out war against the language limitations itself. |
Posts: 8 / Nickname: sebastiank / Registered: September 19, 2005 2:05 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
December 2, 2009 4:06 AM
|
Ray,
I think you are confusing Object Oriented Analysis, Design and Modelling with Object Oriented Programming. The term "Object Oriented" means something completely different in OOA/OOD/OOM than in OOP. In OOP, objects encapsulate behaviour, in OOA/OOD/OOM objects encapsulate attributes and relations. See: http://www.jroller.com/sebastianKuebeck/entry/two_kinds_of_object_orientation http://www.jroller.com/sebastianKuebeck/entry/object_orientation_who_cares And you are right. The OOA/OOD/OOM approach doesn't solve the problem of how to distribute behaviour. OOP does that by nature. |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
December 6, 2009 5:07 AM
|
I think that the attempt to oppose OOA/OOD/OOM to OOP is the bad idea in the sense that the final result of all this exercise is the implementation (that is, the result of OOP). If the design is bad, there won't be any good code from it. I heard many times from people who claim to do the analysis and high level design that they do not care about details. But details pop up when you implement some design in code. The less details are not spoken out at the design phase, the better implementation will be.
Besides, there is no need to oppose Scala or functional programming to Java, C#, etc. Each language has its own issues and limitations due to the limited set of keywords and the semantics behind that syntax. One language does some things better than another. But these better designed features come because of the analysis of predecessors. It does not seem the case with DCI. It is an attempt to formalize the process and the implementation at the same time and this never worked together. By the way, even in Java you can separate the state and actions or communications without any problems. Simply sometimes (or, maybe, quite often) there is not enough time to do that consistently. Another example for what DCI missed, but this one is from the non-OO world, is the well-known relational databases. Those exist for over two decades and seem to continue to exist without any problem by better implementing the old MVC, not DCI. |
Posts: 6 / Nickname: drozenbe / Registered: November 26, 2009 4:00 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
December 6, 2009 8:33 AM
|
Additionally to the previous comment. The example with bank account in the original article is not the right one to illustrate the problem. That should be well known to the authors. The problem with the example is that any banking is backed by the database, nowadays with a relational database which is used to store any relevant data. It is the well known fact that relational databases do not fit into the OO paradigm and as such are under the scrutinity for the last two decades - that is, from the moment they were invented and implemented. So, the database design actually dictates the way how software is decomposed into specific classes, not the imaginery description of how we think we perform transactions on the account.
In relational databases they have currently four normal forms, but I doubt you find any database in the production cycle that is normalized further than the second normal form. This is due to the requirements to make transactions in 'real time'. With further database normalization you never get to the point of extracting any data in 'real time'. From my personal experience, once we did the acceptance testing and compared the existing database and the new (normalized without any consideration to the everyday tasks) one. The existing database provided extracts of data efficiently while the new one could not get any data on a relatively small number of rows - multiple joins killed the possibility to get any data in reasonable time. The point I wanted to make here is that the compain and the example should reflect the actual OOD/OOP. The one that is used by the authors is irrelevant to the topic. |
Posts: 2 / Nickname: banq / Registered: January 6, 2010 3:59 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
January 7, 2010 8:02 PM
|
DCI's "how to implement" is too complicated , traits is not new thing, just like AOP's static weaving.
Domain Events is another way: Account owner send event to his account, and the source account do his balance, after that it will send domain events to target account, let target account update its balance. this is EDA architecture. see how it do in java with entity(data model) Injection: http://www.slideshare.net/banq/jdonframework-2734177 |
Posts: 2 / Nickname: banq / Registered: January 6, 2010 3:59 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
January 11, 2010 6:15 PM
|
sorry, the url in the last post should be:http://www.slideshare.net/banq/ddd-framework-for-java-jdonframework-2881760
I can't modify it. |
Posts: 8 / Nickname: sebastiank / Registered: September 19, 2005 2:05 AM
The DCI Architecture: Supporting the Agile Agenda
January 31, 2010 9:43 AM
|
Jim Coplien's talk "The DCI Architecture: Supporting the Agile Agenda" recorded at Øredev 2009, Sweden:
http://vimeo.com/8235574 |
Posts: 1 / Nickname: markleem / Registered: December 14, 2010 8:25 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
December 14, 2010 2:31 PM
|
In the "Other bits" section there is statement about business rules and how DCI does not provide a convenient way to capture them. You can look at the book "Streamlined Object Modeling" by Nicola, et al and see if that might work. Since the patterns are based on the relationships between objects, and not the objects themselves, mixing in the required behavior might be straightforward.
Mark |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 21, 2009 8:51 PM
|
By the way, Jim, don't take my rant personally. However, I'm trying to get you to think clearly.
If you are going to present a solution to something, you actually need to describe: (1) what the problem is (2) what contributions you can make (3) experimental results, including prototypes, field studies and project data More importantly, practitioners have a hard time relating to abstract concepts when there is no connection to a real world problem they have. By presenting the strawman that "programmers just don't get MVC, but it works", you're basically saying all we really need to do is use something correctly. At which point, I'm wondering why the rest of the article isn't focused on teaching it correctly. Instead, the article diverges and becomes a sermon about how we've all overlooked some practically fundamental architectural concepts -- "traits", if you will. Actually, in my 14 years as a programmer, my biggest benefit to an architecture that includes a GUI is what I call the designer-developer facade. Pretty much every system I've seen others build gets this facade incorrect, because once you have to dynamically vary the UI -- for any reason -- you take the design tools out of the designers hands and force him/her to describe the interaction effects to a developer. This doubles resources, and frequently the developer is untrained in how to program complex reactive systems where arbitrary events can occur. As a result, copious bugs pour in. The end result is frequently event handlers with ad-hoc case statements. There are a few exceptions. For instance, the best selling video games Crash Bandicoot 1 through 3 were architected by one of the top 5 Lisp programmers in the world: Andy Gavin. After several iterations, it was stratified into two main subsystems: a Lisp language for game engine subsystem programmers and a DSL for artists and scene designers. More recently, two members from that 9 person video game company (including cofounder Jason Rubin) started a dotCOM called Flektor, which embodied much of the same principles. So it is possible to create a designer-developer facade. But you fail to tell me how to do this (I know how, but just follow me). And, actually, your traits don't tell me anything about temporal constructs, which is a fundamental element of reactive systems and composing a realistic user's mental model. Your traits also give the appearance that you're creating mini-classes to provide ad-hoc case statements. The only difference between your classes and an ad-hoc case statement is that you've got type-checking; you've added a little bit of structure. In fact, Odersky recognizes this by providing a switch statement on steroids that can do structural pattern matching. However, you don't explain why that incremental structure improves code clarity, testability or conceptual design. You also neglect that a parts-centered object model gives you stronger compile-time type checking for what you are trying to accomplish than a specialization-centered object model, hence why you mentioned trying to avoid traditional class inheritance. However, all you do is provide extension methods with a friendship relationship to a class. That's not an awful thing, and the C++ Client/Attorney idiom can be used to good effect, but it is an implementation detail far apart from the architectural level that MVC addresses. It's also far apart from the level of abstraction of considering a system with an architectural constraint of a *pure* developer-designer facade. Pure abstractions are much harder to design than pure functions, but they give us the ESSENCE Brooks' talks about. Yet, should these abstractions change at the architectural level, they are changing to reflect real world realities. If the roles of designers and developers change, then they will likely change in ways that allow each person at opposite ends of the role the least amount of grief possible. For that reason, you stabilize design around that architectural constraint, not MVC or DCI. |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 4:41 AM
|
> By the way, Jim, don't take my rant personally. However,
> I'm trying to get you to think clearly. I'm happy to reciprocate. > If you are going to present a solution to something, you > actually need to describe: > > (1) what the problem is > (2) what contributions you can make > (3) experimental results, including prototypes, field > studies and project data To be a deconstructionist, you just presented a solution to my problem without either telling me what problem you see in my writing, what contribution to plan to make, or any data supporting your claim. There are many styles of writing for many audiences. I teach English composition in Universities and, for what it's worth, have written some critically acclaimed books and have often been commended by no less than the ACCU folks for writing style alone. Perhaps you expected something different than what we wrote. That's O.K. No one forces you to buy okra when you go to the store. Don't accuse the vendor for selling okra. > More importantly, practitioners have a hard time relating > to abstract concepts when there is no connection to a real > world problem they have. This article introduces the architecture, with examples. It is the first in an article series. I wanted to leave room for Richard and others to follow up with their concrete examples insubsequent articles. > By presenting the strawman that "programmers just don't > get MVC, but it works", Er, where does the article say that? > Instead, the article diverges and becomes a sermon about > how we've all overlooked some practically fundamental > architectural concepts -- "traits", if you will. Traits are just a shill. Don't confuse the example with the fundamentals of the problem and solution. Yes: we've overlooked the fundamental concepts. Now we have a solution. Traits are one way of rendering the solution but they may not be the only one. So I think your concern is at least grounded in that misunderstanding. I think your concern is actually more fundamentally displaced, but suffice to point out this ignorance at this point. > Actually, in my 14 years as a programmer, my biggest > benefit to an architecture that includes a GUI is what I > call the designer-developer facade. And what does that have to do with the price of peanuts? > But you fail to tell me how to do this [create a designer-developer facade] (I know how, but > just follow me). Er, that's not the point of the article nor what we are doing. From this point on, I think your inferences draw on the above misunderstandings and so don't need to be visited one-on-one. In a nutshell, the problem is that 1. OO is supposed to capture mental models; 2. There are mental models that we missed; 3. Roles and the algorithms that run through them are the missing part, and 4. DCI makes it possible to express those in the code. There is nothing about facades. Traits are one technique, not the essence. It took me ten years of Trygve beating on me night and day to see this clearly. Maybe when your 14 gets up to my 40, you'll get it, fine young man :-) Please think clearly. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 7:46 AM
|
@It took me ten years of Trygve beating on me night and day to see this clearly. Maybe when your 14 gets up to my 40, you'll get it, fine young man :-)
I hope the secret to writing great software isn't 40 years of experience. Surveys show the average career in high-tech is 7. You need to reconsider your end game. I may be dead in 26 years. :-) @From this point on, I think your inferences draw on the above misunderstandings and so don't need to be visited one-on-one. Maybe... but were my examples of existing technology like Struts ans Seam examples that you could actually relate to? Have you used these technologies? If not, then I'm giving you technical ideas to continue this debate. At which point, all you are going to hear/see is "I'm trying to get you to think clearly." If you think my technical examples are something you can't relate to, then say so. I have a wide breadth of experience, but I have never worked beside you and despite reading all of your books don't have any knowledge of your real-world project experiences. I know you as "the C++ guy on my bookshelf." |
Posts: 1 / Nickname: mfeathers / Registered: July 27, 2003 3:43 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 5:22 AM
|
Trygve, Jim, it's great to see a full exposition of this. The one thing which strikes me, though, is that you make your argument in terms of "going back to the user's head" and then you add roles to a use case description which does not mention them.
If we're going back to the user's head ("Data: representing the user's mental model of things in their world") wouldn't we be better off with the use case itself rather than the role annotated description. It seems that in your process, you take the user's view and then substitute for it an anthropomorphic view which is convenient for us as designers -- even to the point of privileging the source account role (you give it the self for the behavior). I don't there that there is anything wrong, per se, but given the original goal, it seems to me that having behaviors which were named specifically after the use case would make sense. They would be like procedures or multi-methods, not strongly associated with either the source or destination roles. People adopt that model now, by formulating transaction objects which map to the user's conception of an interaction. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 8:05 AM
|
@ People adopt that model now, by formulating transaction objects which map to the user's conception of an interaction.
Are you referring to Martin Fowler's Transaction Script pattern? I couldn't gather what "that" is that you're referring to. http://martinfowler.com/eaaCatalog/transactionScript.html If so, Transaction Scripts in my experience are horrible for interactivity: it requires a round trip to the server to determine validation failed. You don't have a notion of validation or business rules. Transaction Scripts also poorly model multi-object interactions that take place prior to the user clicking Commit (or some facsimile). |
Posts: 20 / Nickname: raoulduke / Registered: April 14, 2006 11:48 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
June 24, 2010 2:06 PM
|
hey, anybody have any okra?
|
Posts: 3 / Nickname: sshaw / Registered: April 2, 2003 3:33 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
June 27, 2010 10:41 PM
|
Found some here http://en.wikipedia.org/wiki/Okra
|
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 8:56 AM
|
@To be a deconstructionist, you just presented a solution to my problem without either telling me what problem you see in my writing, what contribution to plan to make, or any data supporting your claim.
OKay, I'll bite. You are way more infatuated with the abstract, academic angle of this topic than concrete examples of how to build working systems. To prove my point, your references are all academic stuff, such as Alan Kay's and Doug Englebart's visions of computing. There is nothing wrong with linking to these things, but I am dumbfounded as to why you aren't directly linking to the following: @DCI implementations also exist in C#/.Net (Christian Horsdal Gammelgaard), Ruby (Steen Lenmann), Python (David Byers and Serge Beaumont), and Groovy (Lars Vonk). The Qi4J environment (Richard Öberg and Steen Lehmann) is pushing forward the ability to express traits in a Java environment. Why aren't you linking me directly to implementations so I can play around with examples? One of Kay's big tenets is learning should be constructive. Instead of letting me play, you're linking me to more theory that I have to digest before I can go play. No, no, no. Just no. Let me play with the code. Instead, Bill Venners is linking for you and providing us with the url to Qi4j. When you were standing next to Robert Cecil Martin at the MIT agility conference, the differences between you were so striking. Most practitioners I know in the audience felt that they could relate much better to Uncle Bob, because he was expressing stuff they were comfortable with: write the tests and then the code. Simple, pragmatic stuff. I love approaches like Bertrand Meyer's, where he has students work on a 150,000 SLOC Eiffel code base and gives them the freedom to break stuff and understand why thngs are the way they are. With programmers, it can be very hard knowing your audience. When speaking or writing, I've done much worse than you have here. The primary enemy is the fact it is so darn tough to get a roomful of 15 programmers who share common backgrounds, both in theory and practice. However, there is one thing you can pretty much rely on programmers knowing how to do: testing and debugging code. Steve McConnell got it right in Code Complete: construction is the only phase of software you can provide reliable advice and common ground for. On a separate matter, your diagrams are very poor. You have spaghetti lines tracing from your DCI half to your MVC half. You should explore the benefits of consistent positional notation in your diagrams. The benefits are well-argued by the CASE Method folks. Actually, these spaghetti lines give the impression that the name-space relationships in DCI are going to be inherently hard to visualize, and in most cases they are probably actually easy to visualize. In fact, one of the "features" of Data Flow Diagrams championed by DeMarco is that they give you "deep zoom": top-down design in a DFD is trivial because all you do is "step into" a process to specify its details at a lower layer in the problem domain. In fact, because control is not specified in a DFD, you can also "step over" without worrying about missing something. At any given point in time, you are looking at one instantiation of a navigation relationship. |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 0:11 PM
|
> You are way more infatuated with the abstract, academic
> angle of this topic than concrete examples of how to build > working systems. To prove my point, your references are > all academic stuff, such as Alan Kay's and Doug > Englebart's visions of computing. There is nothing wrong > with linking to these things, but I am dumbfounded as to > why you aren't directly linking to the following: > > @DCI implementations also exist in C#/.Net (Christian > Horsdal Gammelgaard), Ruby (Steen Lenmann), Python (David > Byers and Serge Beaumont), and Groovy (Lars Vonk). The > Qi4J environment (Richard Öberg and Steen Lehmann) is > pushing forward the ability to express traits in a Java > environment. > > Why aren't you linking me directly to implementations so I > can play around with examples? One of Kay's big tenets is > learning should be constructive. Instead of letting me > play, you're linking me to more theory that I have to > digest before I can go play. > > No, no, no. Just no. Let me play with the code. > I'm not sure there's anyplace where that code has been made public. I'll ask. It is not secret or anything, but may not have been released publically. I'll post here if I find a link. Anyway, this is an idea article. We'll be publishing more articles exploring this area that will be more hands on. We'll do something on Qi4J, but I would point out that Qi4J isn't DCI. What they have in common is that DCI has a concept of roles that is implemented with this concept traits, and Qi4J provides a way to do that trait-like concept in Java. |
Posts: 8 / Nickname: sebastiank / Registered: September 19, 2005 2:05 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 23, 2009 1:07 AM
|
It think what's missing in the article to understand DCI is the definition of role in this context:
We will now look at how the word role is generally used and see how this usage can help us build an intuition about our use of the word in object oriented programming. Most people will probably associate the word role with a part played by an actor in a theatrical performance. Oxford [9] gives its origin: "from obsolete French roule ‘roll’, referring originally to the roll of paper on which an actor’s part was written." (Note that this means the script, not the performance!) Oxford [10] has a fitting definition: "Actor’s part; one’s function, what one is appointed or expected or has undertaken to do." This maps nicely on to our use of roles for naming the participants in a system of collaborating objects; the role is a reference to an object; it represents the object’s function, what it is delegated or expected or is required to do. Excerpt from: http://heim.ifi.uio.no/trygver/2007/roles07-rolesandclasses.pdf For examples see Jim's book draft: http://sites.google.com/a/gertrudandcope.com/info/Publications/LeanArchitecture.pdf |
Posts: 2 / Nickname: horsdal / Registered: March 16, 2009 1:44 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 6:31 AM
|
> > You are way more infatuated with the abstract, academic
> > angle of this topic than concrete examples of how to > build > > working systems. To prove my point, your references > are > > all academic stuff, such as Alan Kay's and Doug > > Englebart's visions of computing. There is nothing > wrong > > with linking to these things, but I am dumbfounded as > to > > why you aren't directly linking to the following: > > > > @DCI implementations also exist in C#/.Net (Christian > > Horsdal Gammelgaard), Ruby (Steen Lenmann), Python > (David > > Byers and Serge Beaumont), and Groovy (Lars Vonk). The > > Qi4J environment (Richard Öberg and Steen Lehmann) is > > pushing forward the ability to express traits in a Java > > environment. > > > > Why aren't you linking me directly to implementations so > I > > can play around with examples? One of Kay's big tenets > is > > learning should be constructive. Instead of letting me > > play, you're linking me to more theory that I have to > > digest before I can go play. > > > > No, no, no. Just no. Let me play with the code. > > > I'm not sure there's anyplace where that code has been > made public. I'll ask. It is not secret or anything, but > may not have been released publically. I'll post here if I > find a link. > > Anyway, this is an idea article. We'll be publishing more > articles exploring this area that will be more hands on. > We'll do something on Qi4J, but I would point out that > Qi4J isn't DCI. What they have in common is that DCI has a > concept of roles that is implemented with this concept > traits, and Qi4J provides a way to do that trait-like > concept in Java. As for the C# implementation mentioned I have only made a small proof-of-concept example, but I am working on a larger example, which will give a better impression of how nicely (or not) my implementation would work in a real application. The C# approach is to use C# interfaces for methodless roles, use C# interfaces and extension methods for methodful roles, and just use POCOs for context and domain object. To be concrete the following is a really short example: namespace AccountSample { // Methodless roles public interface TransferMoneySink { } // Methodfull roles public interface TransferMoneySource { } public static class TransferMoneySourceTraits { public static void TransferFrom(this TransferMoneySource self, TransferMoneySink recipient, double amount) { Account self_ = self as Account; Account recipient_ = recipient as Account; // Selfcontained readable and testable algorithm if (self_ != null && recipient_ != null) { self_.Withdraw(amount); self_.Log("Withdrawing " + amount); recipient_.Deposit(amount); recipient_.Log("Depositing " + amount); } } } // Context object public class TransferMoneyContext { // Properties for accesing the concrete objects relevant in this context through their methodless roles public TransferMoneySource Source { get; private set; } public TransferMoneySink Sink { get; private set; } public double Amount { get; private set; } public TransferMoneyContext() { // logic for retrieving source and sink accounts } public TransferMoneyContext(TransferMoneySource source, TransferMoneySink sink, double amount) { Source = source; Sink = sink; Amount = amount; } public void Doit() { Source.TransferFrom(Sink, Amount); // Alternatively the context could be passed to the source and sink object. } } // Abstract domain object public abstract class Account { public abstract void Withdraw(double amount); public abstract void Deposit(double amount); public abstract void Log(string message); } // Concrete domain object public class SavingsAccount : Account, TransferMoneySource, TransferMoneySink { private double balance; public SavingsAccount() { balance = 10000; } public override void Withdraw(double amount) { balance -= amount; } public override void Deposit(double amount) { balance += amount; } public override void Log(string message) { Console.WriteLine(message); } public override string ToString() { return "Balance " + balance; } } // Test app public class Program { public static void Main(string[] args) { SavingsAccount src = new SavingsAccount(); SavingsAccount snk = new SavingsAccount(); Console.WriteLine("Before:"); Console.WriteLine("Src:" + src); Console.WriteLine("Snk:" + snk); Console.WriteLine("Run transfer:"); new TransferMoneyContext(src, snk, 1000).Doit(); Console.WriteLine("After:"); Console.WriteLine("Src:" + src); Console.WriteLine("Snk:" + snk); Console.ReadLine(); } } } |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 7:43 AM
|
@Christian Horsdal
Thanks! Can I ask what .NET libraries you usually use on your projects? I.e., what IoC/DI library? One of the article's claims was DCI enables rich multiobject interaction that can replace object state machines. I see your current form of interaction as somewhat anemic, though - you are using inheritance to give your domain object Account additional capabilities that probably don't belong to it. This is a model smell in my books. The interesting thing is that so far nothing in the original article's top half has been proven, whatsoever. (This isn't a shot at you, Christian - just a critique of the original article.) I'll continue to say that existing approaches are way further in theory&practice than this approach. MEF is a good example, albeit I feel MEF has many shortcomings and reasons why I don't use it - it at least gives me a reference point. But, more importantly, in my experience there is nothing new here and nothing "agile" here, either. Instead, we're just creating a different way to do the SAME typechecking we were doing before - "Fortune 100"-style source code controls. Businesses have more basic concerns that are better talking points for "mental models". One company we work with had their two head IT people tell us the biggest problem they face is silos. So what is there solution? Build a data warehouse - another silo, What ends up happening is nobody is accountable because there is no electronic workflow attached to the analysis that comes out of the warehouse data mining aventures. People print out sheets of paper, hand them out in the office, and people are supposed to be doing their work -- but they don't. Why? My guess is that people find it a pain in the butt to navigate back-and-forth between the data warehouse silo and their back office apps where they (re-)enter everything in. Then on another level you have what I call the designer-developer facade, which is how you actually facilitate rapid prototyping of user interfaces. There is a reason why companies pay such a ridiculous amount of money for tools like iRise: it gets the client talking and thinking. |
Posts: 2 / Nickname: rsm / Registered: March 24, 2009 3:58 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 11:37 PM
|
@John it appears, you have knowledge of so many theories and technologies, that it's hard to believe you still have a time to be a practitioner :)
As I can see, DCI is not about how to write lines of code in any given programming language. It's not even about the idea of coding anything, nor writing source neither code nor grammar specifics of C# or Smalltalk. DCI is going further. If you want to create a system based on ideas of DCI you need something more than just a bunch of source files. Believe me, the source code could be seen as an object, everything could be registered in an object oriented database and the property of identity will allow to keep versions and interactions between system objects. System objects like class, field, method, user, access levels etc. Based on that system one could build an application modeler/generator capable of producing programs working in DCI philosophy in the environment of the mentioned system. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 5:11 AM
|
@John it appears, you have knowledge of so many theories and technologies, that it's hard to believe you still have a time to be a practitioner :)
There are five people in the world who remember everything that has ever happened to them. I'm not quite there, but my memory is prolific. The hard part is not being burned out. Working myself up into a white-hot concentration and sustaining it simply isn't possible. My rule of thumb is to only promise one good idea every three months, and guarantee mediocrity the rest of the time (while ideally doing no harm). @As I can see, DCI is not about how to write lines of code in any given programming language. It's not even about the idea of coding anything, nor writing source neither code nor grammar specifics of C# or Smalltalk. DCI is going further. If you want to create a system based on ideas of DCI you need something more than just a bunch of source files. I read Trygve's papers last night. It seems he feels object polymorphism makes code unreadable (which I hear from F# programmers all the time) and traits are the key concept. I enjoyed reading his funny rant about unreadable code. However, his quote of Serge Beaumont was probably the best "strong content" in all the writing. Yet, BabyIDE has a couple of design flaws and its explanation doesn't map use cases to code, which strongly diminishes proving the point "it is about mental models". |
Posts: 35 / Nickname: seanl / Registered: March 8, 2002 5:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 5:50 AM
|
@Yet, BabyIDE has a couple of design flaws and its explanation doesn't map use cases to code, which strongly diminishes proving the point "it is about menta models".
Does "use cases" mean Use Cases? Is the goal really to map Use Cases to code? Is that even desirable or achievable? Caveat: I didn't read the article on BabyIDE. Still, I think they are valid questions. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 1:09 PM
|
> Does "use cases" mean Use Cases? Is the goal really to map
> Use Cases to code? Is that even desirable or achievable? > Caveat: I didn't read the article on BabyIDE. Still, I > think they are valid questions. Use cases are useful for testing. They also give you a good idea for how well your class model describes the problem space (i.e., do i have lots of artificial boilerplate like in Spring vs. virtually no boilerplate in Seam). |
Posts: 1 / Nickname: infernoz / Registered: November 30, 2005 1:31 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 9:42 AM
|
> > > You are way more infatuated with the abstract,
> academic > > > angle of this topic than concrete examples of how to > > build > > > working systems. To prove my point, your references > > are > > > all academic stuff, such as Alan Kay's and Doug > > > Englebart's visions of computing. There is nothing > > wrong > > > with linking to these things, but I am dumbfounded as > > to > > > why you aren't directly linking to the following: > > > > > > @DCI implementations also exist in C#/.Net (Christian > > > Horsdal Gammelgaard), Ruby (Steen Lenmann), Python > > (David > > > Byers and Serge Beaumont), and Groovy (Lars Vonk). > The > > > Qi4J environment (Richard Öberg and Steen Lehmann) is > > > pushing forward the ability to express traits in a > Java > > > environment. > > > > > > Why aren't you linking me directly to implementations > so > > I > > > can play around with examples? One of Kay's big > tenets > > is > > > learning should be constructive. Instead of letting > me > > > play, you're linking me to more theory that I have to > > > digest before I can go play. > > > > > > No, no, no. Just no. Let me play with the code. > > > > > I'm not sure there's anyplace where that code has been > > made public. I'll ask. It is not secret or anything, > but > > may not have been released publically. I'll post here if > I > > find a link. > > > > Anyway, this is an idea article. We'll be publishing > more > > articles exploring this area that will be more hands > on. > > We'll do something on Qi4J, but I would point out that > > Qi4J isn't DCI. What they have in common is that DCI has > a > > concept of roles that is implemented with this concept > > traits, and Qi4J provides a way to do that trait-like > > concept in Java. > > As for the C# implementation mentioned I have only made a > small proof-of-concept example, but I am working on a > larger example, which will give a better impression of how > nicely (or not) my implementation would work in a real > application. > The C# approach is to use C# interfaces for methodless > roles, use C# interfaces and extension methods for > methodful roles, and just use POCOs for context and domain > object. To be concrete the following is a really short > example: > > namespace AccountSample [i]....excessive code, with casting![/i] > I agree with an earlier poster, about DCI, IoC, AOP, and event based programming, all are seriously flawed: * they obfuscate code * they make it even harder to design, understand, test, and especially debug side-effects! * they can lead to ironically unexpected, and nasty, binding side-effects, including hard to trace data security and thread-safety issues. * indirect binding can seriouly slow down execution, because too much indirection can sabotage VM runtime optimisations. * they are another place for the code to break, due to subtle bugs. * any API which injects code, relies on a less secure code definition, or uses reflection to access object internals, maybe a security risk, or introduce hard to debug runtime bugs. I looked at Qi4j, and found numerous stupid mistakes on the web site, including in the code examples, this didn't bode well for design and code quality, but I was still shocked at just how full of over-abstracted IoC, and verbose framework boilerplate code, the examples were! The examples even included reflection code, when a Facade class would have been simpler, and been ripe for VM runtime optimisations. IMHO, a transactional money transfer would be better managed by separate immutable reversable command, multi-object lock, and transaction objects; these could be inherently thread-safe, easy to track, easy to test, trivial to audit, and be made to enforce business rules, without any need for arcane frameworks, IoC, AOP, dodgy injection wild-cards, or other unsafe dynamic programming recklessness. Have a read the Specs? Really? That’s so unagile section of http://www.joelonsoftware.com/items/2009/03/09.html I suspect that the main reason for this back-breaking dynamic language nonsense, is that some Agile programmers have to do over-kill code abstraction, because of inadequate or out-of-date specifications; I've been there, it was not fun, it made quoting a gamble, due to creeping featurism, so caused significant delays for software delivery. The developing financial recession/depression process has forced Development, at my employer, to realise that this specification inadequacy was untenable, so we now insist on bounded, signed-off specifications, for bespoke customer work; this allows realistic quoting, and rebuffs cheeky customer bugs, for the new, and often expensive, functionality. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 27, 2009 0:11 PM
|
> Have a read the Specs? Really? That’s so unagile
> section of > http://www.joelonsoftware.com/items/2009/03/09.html > I suspect that the main reason for this back-breaking > dynamic language nonsense, is that some Agile programmers > have to do over-kill code abstraction, because of > inadequate or out-of-date specifications; I've been > there, it was not fun, it made quoting a gamble, due to > creeping featurism, so caused significant delays for > software delivery. > > The developing financial recession/depression process has > forced Development, at my employer, to realise that this > specification inadequacy was untenable, so we now insist > on bounded, signed-off specifications, for bespoke > customer work; this allows realistic quoting, and rebuffs > cheeky customer bugs, for the new, and often expensive, > functionality. Joel is great at the Harvard Business Review-style teethbrushing lectures. It works. Quoting from the section *What does a program manager do?*: "A good rule of thumb is that it takes about one program manager for every four programmers." We have six program managers and four full-time developers. For SaaS, it is a phenomenal model. Your other comments were dead-on. The trouble is vendors push all these techniques to big companies trying to do real-time or same-day-services. Sad fact is the mainstream has no alternatives. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 22, 2009 1:11 PM
|
If implementations aren't public, they're vaporware. Duke Nukem Forever could be using a DCI Architecture for all I know, but DNF is still vaporware. This is like when academics site a paper with the promise it will be published at a later date, and then never is.
Along the lines of ideation, consider asking Glenn Block, Hamilton Verissimo or Nicholas Blumhardt to talk about .NET's Managed Extensibility Framework. Rinat Abdullin could also be another interesting person to talk to. I hope you don't find my feedback out-of-place, Bill. Part of the reason people publish idea articles is to get critiques. And I'm the epitome of blunt -- it sometimes overshadows my thoughtfulness and how attentive to the topic I am actually being. You build a community based on working code. If it's taken 10 years just to get Jim and Trygve see eye to eye, there must have been some code written out there to publish? Even if you can't provide working code for your idea, you can at least provide working code for existing approaches and show why they're so inadequate. And if you make the case that your approach is similar to but less nerdy than FSMs, show it. I found this particular point hardest to grasp, as it is not clear to me yet how Jim sees me taking advantage of my spatial intelligence in the same way a statechart does. Moreover, new GUI toolkits like Silverlight formerly use FSMs in their API -- it's an old academic idea finally put into practice. For what it's worth, I carefully incorporate architectural constraints for dynamically varying things by role, and I reason about parts of my system using FSMs. I see these two approaches as complementary, not divisive nerd-centric vs. user-centric. |
Posts: 15 / Nickname: admin / Registered: January 17, 2002 3:57 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 6:15 AM
|
> If implementations aren't public, they're vaporware. Duke
> Nukem Forever could be using a DCI Architecture for all I > know, but DNF is still vaporware. This is like when > academics site a paper with the promise it will be > published at a later date, and then never is. > The reason I wanted to publish this article is to give readers some new ideas to think about. So I think you're a bit hung up on the code aspect. This article is about the ideas. I think implementing DCI is awkward in most of today's popular programming languages. That doesn't mean its a bad idea. Implementing an object-oriented program in C or Fortran is awkward. Scala's traits may capture it nicely, and I suspect Ruby's mixins would too. The paragraph that mentions languages and names I suspect is there to give some credit to the folks who did that, but what I think they did is simply implement the account example in the languages mentioned. But this isn't about how to do things given today's programming languages, but rising above that, asking how can you make code easier to understand. This article is academic in the sense of people aren't using DCI in mainstream programming circles. I don't see that as something wrong. It is a new idea, an attempt to improve things. Maybe it will pan out maybe it won't. It is also still evolving. But the whole thing is aimed at solving a very real-world problem, which is that it is hard to understand programs. One of the things I took away is that I don't believe I've thought about designing objects to map to the user's mental model. I work hard on naming things and coming up with clear concepts, but from the perspective of programmers working on the code. Domain Driven Design recommends using the same vocabulary used by the domain experts in the code, but that also isn't the same thing as the user's mental model necessarily. Another take-away for me was Trygve's concern that the logic in a traditional OO program is spread out all over the place. So to him OOP was a bit of a step backwards in ease of understanding code compared to procedural programming. DCI is an attempt to improve the understandability of OO programs. Another thing I found interesting was the suggestion that the domain objects be very simple ("dumb, dumb" as Jim put it). This seems to promote what Martin Fowler and Eric Evans called an "anemic" domain model: http://martinfowler.com/bliki/AnemicDomainModel.html These guys complained that you should put more interesting behavior on those objects. Well, this article points out that sometimes you can end up wanting to put too much stuff in those objects, and that different subsets of all that behavior may be needed in different contexts. Well, their notion is that you model that extra stuff in traits, and that the traits would map to roles in the user's mental model. And then in a particular context, or use case, you add on the traits that you need for that context to the dumb domain objects. Now they aren't anemic anymore, and they only have the extra behavior that's needed for the current context. Having worked with Scala for a while now, I've really seen the usefulness of traits, and this article gave me a new idea for how traits could be applied. I'm still not sure how this would make the code more readable, because it seems like things are now spread out among traits. Though I think the home of the algorithm we used to easily see in a procedural program may be the "context". Perhaps Jim or Trygve could clarify that for me. One other place you might want to look if you want to see some DCI code is Trygve's BabyIDE project, which I believe is implemented in Squeak. I have not looked at it, so I don't know what it's status is: http://folk.uio.no/trygver/themes/babyide/babyide-index.html |
Posts: 1 / Nickname: vkelman / Registered: February 20, 2008 3:34 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 20, 2009 10:17 PM
|
> Another thing I found interesting was the suggestion that
> the domain objects be very simple ("dumb, dumb" as Jim put > it). This seems to promote what Martin Fowler and Eric > Evans called an "anemic" domain model Bill, I think article authors were pretty clear on what they think should and what shouldn't go inside domain objects: methods which involve doing something for this single object obviously should be part of the object, methods which involve a complex interaction of multiple objects or involve services orthogonal to domain objects (i.e. transactions, serialization, or CRUD) are better to be outside of domain objects; normally, domain objects shouldn't even know about those methods to avoid coupling. So, domain objects are not anemic / dumb; they just don't try to contain parts not belonging to them. A "container" / business logic layer / context - whatever we call this thing - obtains concrete implementation of those external methods using some kind of IOC/DI and executes them. If this pattern somehow contradicts "pure" OOP, I strongly oppose enforcing pure OOP here. A very interesting variant of this approach called Making Roles Explicit was presented by Udi Dahan. Note, that Udi uses the same term "role" (although he's definitely a developer, not a person from academia :). He shows, among other things, that sometimes business logic layer even maps "roles" = external methods back to domain objects, in case domain objects include suitable functionality. This still keeps roles decoupled from BO. I like how authors emphasize that roles represent behavior, action, rather than object structure. What I don't understand from the above article is why would we want to use traits/mix-ins/extension methods or any other tool to attach those "roles" external to domain objects back to them? To me, these things are external and should belong to business logic layer. |
Posts: 5 / Nickname: trygver / Registered: September 7, 2003 9:58 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
April 21, 2009 0:44 AM
|
A new version of BabyIDE/DCI program and documentation is now available from
http://heim.ifi.uio.no/~trygver/themes/babyide/babyide-index.html The Documentation section gives access to the short article that started this blog and also the main DCI document called "The Common Sense of Object Oriented Programming". The latter document discusses details and rationale for DCI as well as commented code for three examples. The Downloads section includes the latest Smalltalk/Squeak program (image) with examples. Follow the simple instructions to download the program; it is set up so that it is meaningful to programmers without prior experience with Smalltalk/Squeak. It is easiest to run the program under Windows, a bit harder for other operating systems. There are also files for Squeak programmers who want to install BabyIDE and the examples in their favorite Squeak image. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 7:15 AM
|
@Another thing I found interesting was the suggestion that the domain objects be very simple ("dumb, dumb" as Jim put it). This seems to promote what Martin Fowler and Eric Evans called an "anemic" domain model [...] These guys complained that you should put more interesting behavior on those objects.
Well, that's easy to reconcile. Evans/Fowler vs. Coplien/Reenskaug is not a battle of diametrically opposed forces. Instead, they're both wrong. The big idea behind dynamic, multi-object interaction is that it is composed at run-time. You will have code fragmentation in order to do this. As you pointed out, their solution just pushes the fragmentation around and into traits. They're moving mounds of dirt, not setting up foundations for an architecture. Rich domain models are wrong because the assumption is placing logic in one place (a domain class) is a good idea. Maybe, but you lose a degree of freedom and are creating an unstoppable geometric progression. Then there are awkward "N-Body Problems" where objects need to coordinate and no one object is in charge. Anemic domain models are wrong because they flatten an architecture into orthogonal layers, requiring developers to pass tramp parameters to pass an object across multiple layers. This is fundamentally not OO, it is a data-driven CRUD/USER pipeline. This is the kind of app Spring and Struts and much of ASP.NET encourage writing. The POJO Facade pattern is a great example, and the book "J2EE Design Patterns" is a great example of OO anti-pattern after OO anti-pattern: breathtaking, really! Until J2EE5 and EJB3, Java land has been very far from OO theory&practice. A major culprit here is buzzwords. So you'll forgive me if I snort when I see sections of an article with the header: "in spite of capturing structure, OO fails to capture behavior". The whole point of the GoF design patterns was to explain how to do dynamic substitution of behavior. A more even handed approach is what Microsoft is trying to evangelize w/ Acropolis, Prism, MEF and Oslo, but very few seem to be adopting due to its immaturity. Redhat's JBoss also deserves some credit. Are you familiar with Redhat's JBoss and Microsoft's upcoming products? |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 3:18 PM
|
> Rich domain models are wrong because the assumption is
> placing logic in one place (a domain class) is a good > idea. ... > > Anemic domain models are wrong because they flatten an > architecture into orthogonal layers, requiring developers > to pass tramp parameters to pass an object across multiple > layers. > I think I wasn't clear. Let me try to clarify what I mean, because I wasn't trying to say that DCI promotes anemic domain models. Instead it challenges a basic assumption inherent in the notion of an anemic domain model. The assumption is that an object has a class. Basically what we've been doing in OO modeling is designing classes whose names often map to the domain. So if there's an "account" in the problem domain, then we might have an Account class in the code. But what behavior do we attach to that class? Well, if the class is anemic, then it is just simple behavior of getting and setting data. The class is "dumb," little more than a glorified data holder. If the class is non-anemic, then it will have more interesting behavior that has something to do with the data. In OO we tend to move the behavior that uses data to the classes that have the data.OK. So what happens is that if the account concept is involved in 10 use cases of your application, you may end up placing some behavior for each of those use cases into class Account . Deciding what behavior to put in and what to leave out is the designer's challenge.DCI challenges the assumption that each object has one and only one class. The observation is that objects need different behavior in different contexts. So why not let an object have a different class in each context? The way it shakes out is that you will have an anemic Account class in your design, and different traits that can be mixed into Account to supply just the extra (non-anemic) behavior needed for the use case at hand. And DCI also suggests is that use map these traits to conceptual roles in the user's thinking.Since you like code, let me show you how this maps to Scala, in which you can model it nicely. You can have a anemic class Account , and then mix in one ore more traits at instantiation time. So in the transfer use case, you might write:
What the Scala compiler does with this is create an anonymous class (it creates a class and assigns it a name that includes some dollar signs) that extends SavingsAccount and mixes in TransferMoneySourceAccount , then creates an instance of that. On the JVM then, each object does have one and only one class. But the conceptual account object may have many different classes, one of which is the anonymous class created here that is only used in this one use case.
|
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 6:06 PM
|
Yes, I understand that. I know a lot about traits. I'm being hypercritical, because I hate sucky explanations.
I think too often people try to sound too smart. Realistically, a more appropriate introductory article would be along the lines of what you just said. As I said earlier, compiler syntax features are important b/c the average developer isn't a compiler writer, and it is tricky to get right. For instance, Sather had a way stronger notion of contracts than Eiffel, but never became popular. Also, I think what Coplien/Reenskaug are *aspiring to* with "DCI" is what most good IoC containers such as Nicholas Blumhardt's Autofac do. Thus, I don't see it as a new concept. And, again, I see state machines and roles as complementary. In fact, containers like Autofac have a very Demeter Method Tools feel to them, too. Most people, unfortunately, don't understand IoC and perceive it to be a technique for improving testability or whatever, when really it is best viewed as a data modeling paradigm. @I think I wasn't clear. Let me try to clarify what I mean, because I wasn't trying to say that DCI promotes anemic domain models. Instead it challenges a basic assumption inherent in the notion of an anemic domain model. The assumption is that an object has a class. My objects are aren't classes, either. In fact, my object models are very similar to constraint-based programming. The reason for this is to avoid the cross-product statespace problem you get with anemic domain models. This isn't DCI - it's just good modeling with math to back it up. It makes it much easier to comprehend performance, too. |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 6:26 PM
|
@DCI challenges the assumption that each object has one and only one class.
Just to be clear, this is a problem space abstraction issue. Traits are really just a way to place constraints on the object model. However, DCI does not fundamentally invent anything new at all -- that's very important to realize, because most people don't understand this due to never being taught it. Calling this an architecture is just buzzword stuffing in a day and age where everybody gets promoted to architect to make them feel important. Fundamentally, we're saying, "hey, let's practice OO for a change". That's not a "new vision for OO", but rather a change in human behavior. You can't call change in behavior an architecture, though - especially when so much code out there is crap and shows there is no movement in place. |
Posts: 9 / Nickname: roybatty / Registered: September 15, 2003 4:57 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 24, 2009 8:51 PM
|
> OK. So what happens is that if the account concept is
> involved in 10 use cases of your application, you may end > up placing some behavior for each of those use cases into > class Account . Deciding what behavior to put> in and what to leave out is the designer's challenge. > > DCI challenges the assumption that each object has one and > only one class. The observation is that objects need > different behavior in different contexts. So why not let > an object have a different class in each context? The way > it shakes out is that you will have an anemic > Account class in your design, and different> traits that can be mixed into Account to> supply just the extra (non-anemic) behavior needed for the > use case at hand. And DCI also suggests is that use map > these traits to conceptual roles in the user's thinking. > Bill, thank you for that explanation. OK. So what happens is that if the account concept is involved in 10 use cases of your application, you may end up placing some behavior for each of those use cases into class Account . Deciding what behavior to putin and what to leave out is the designer's challenge. That has always been my fundamental problem with OO languages like Java and C#. Grouping behavior with different contexts in the same class isn't right, but as you stated, what do you leave in and out. Maybe that's why I've always been intrigued with Common Lisp's CLOS style of OO. |
Posts: 4 / Nickname: vijaykandy / Registered: January 25, 2007 6:08 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 3:15 PM
|
> DCI challenges the assumption that each object has one and
> only one class. The observation is that objects need > different behavior in different contexts. So why not let > an object have a different class in each context? The way > it shakes out is that you will have an anemic > Account class in your design, and different> traits that can be mixed into Account to> supply just the extra (non-anemic) behavior needed for the > use case at hand. And DCI also suggests is that use map > these traits to conceptual roles in the user's thinking. > > Since you like code, let me show you how this maps to > Scala, in which you can model it nicely. You can have a > anemic class Account , and then mix in one ore> more traits at instantiation time. So in the transfer use > case, you might write: > >
Here's a stupid question and I don't mean to be rude but why not just use the term trait[/t] instead of DCI Architecture? Does DCI differ from (or add anything new to) a trait in Scala or Squeak? |
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 25, 2009 5:21 PM
|
> > DCI challenges the assumption that each object has one
> and > > only one class. The observation is that objects need > > different behavior in different contexts. So why not > let > > an object have a different class in each context? The > way > > it shakes out is that you will have an anemic > > Account class in your design, and> different > > traits that can be mixed into Account to> > supply just the extra (non-anemic) behavior needed for > the > > use case at hand. And DCI also suggests is that use map > > these traits to conceptual roles in the user's > thinking. > > > > Since you like code, let me show you how this maps to > > Scala, in which you can model it nicely. You can have a > > anemic class Account , and then mix in one> ore > > more traits at instantiation time. So in the transfer > use > > case, you might write: > > > >
> Here's a stupid question and I don't mean to be rude but > why not just use the term trait[/t] instead of DCI > Architecture? Does DCI differ from (or add anything > new to) a trait in Scala or Squeak? > I can think of two reasons. One is that traits are more general than DCI. So DCI could be thought of one way to use traits, but there are many others. But also DCI attempts to live at a level above language constructs, as a pattern. So traits is one way to implement DCI. There may be others. |
Posts: 35 / Nickname: seanl / Registered: March 8, 2002 5:57 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
May 11, 2009 11:09 AM
|
John,
What is it about those products that appeals to you from an architecture perspective? What is the foundation? |
Posts: 62 / Nickname: zbo / Registered: January 20, 2007 9:22 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
May 11, 2009 1:40 PM
|
What products are you referring to?
I didn't really list products so much as theories. The foundation is quite large, which is why I don't formally define it. Look at it this way: Ted Codd defined 333 guidelines for his relational model. Now suppose you used a fair chunk of relational theory, but then also said to yourself, "gee, that Turing Award winner Charles Bachman guy who was Ted Codd's arch rival in the 70s, he had some good points about navigating large data banks." Fast forward to the late '90s, Roy Fielding is designing Apache and working on his Ph.D on how to design network-based architectures. He advocates disciplined use of hypermedia (REST) as a highly scalable model for information systems. So now you have something like 333 rules from relational theory, and now you tack on more from REST. And so on. Most people don't realize how many theories they use when writing code or simply designing systems. |
Posts: 1 / Nickname: fireblaze / Registered: July 5, 2006 4:30 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
March 17, 2010 8:31 AM
|
>
> No, no, no. Just no. Let me play with the code. I think John Zabroski missed the title of the article which states "The DCI Architecture: A New Vision of Object-Oriented Programming". 1) Its an architecture - hence nothing that you can play with only reason about so play with different implementations of where each implementation is different. |
Posts: 1 / Nickname: fero / Registered: June 22, 2010 8:22 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
June 23, 2010 11:44 PM
|
Hi all I have few remarks and few questions.
I will use word entity for a object which is a domain noun and is mapped to db. Entity class is a class of this object. I've worked 2 years part time (40-80 hours a month) and less than 1 year fulltime (I finished my school a year ago) on a java project which is now 7 years old and was programmed by the team of about 15 developers. We have 376 entity classes and some of them have thousands of lines. We even made a utility classes to put logic inside but I know this is not the final solution: BankAccount{ public void transferTo(BankAccount destination){ new BankTransfer().transferTo(destination); } } E.q. BankTransfer is utility class with methods for source and destination but these methods are still in every BankAccount object, even if we are not doing any transaction at a moment.. After a half year I realized that this is not a good way and we should do something like new BankTransfer(BankAccount source, BankAccount destination).transfer(); but no one is listening to me. Remarks 1. I totally agree with the motivation behind DCI. Classes tend to accumulate code describing interactions between objects from use-cases. A single object can play different roles in different use cases so it is really a mess. 2. I have seen talk by Jim Coplien: Why DCI is the Right Architecture for Right Now on infoq.com and I agree also with that the patterns are overrated. More important is motivation and forces behind them. But I think is important to know them, to know th emotivation behind and because, you can modify them and it is good way to communicate. E.g. "We use visitor pattern." Instead of "We send an object with behavior.. which does.." In Scala or Haskell (my favorite) one is using Strategy pattern all the time but it has no specific name.. Questions 1. When working in java isn't it easier to create single use case classes with the roles as attributes and the methods needed instead of trying to inject some methods to objects? Can that be a valid implementation of DCI? 2. What about processes? How do they relate to DCI? "Business processes don't represent things the business object is doing, rather things being done to the business object.” IMO process is a long running interaction between objects and/or human actors. So entities have process agnostic methods, processes have process specific actions. Process is like a class and process instance is a instance of a process. One explicitelly creates process instances and set objects to roles they play. There are processes which every object has to take. E.g. Every human beeing is created in a process instance called Birth. Not every human has to take a process Marriage, but there can be only one instance of this process in a meantime where a man or a woman is in a role fiancee. One can took this role in more marriages but one after another. But one be a wittness in another marriage instance in the same time. Law suit process is different. One can take the same role in many process instances concurently. If you would like to know more about processes look at presentation on my blog: http://fokot.blogspot.com/2010/01/introduction-to-processes.html The problem process instances solve is not only the problem of use case specific methods in entity classes but also the problem of tracking long running process instances. One can not see flow in a code if it is interrupted by human interactions (spawns multiple transactions). In a process diagram there are actions performed by humans as well as action executed by a system. (The same problem arrises when there are several systems involved or something needs to be doen asynchonously in a single system.) Btw. processes does not mean statemachines or petri nets. This is not the essence of them, flow can be also rule based. My blog: http://fokot.blogspot.com/2010/02/case-handling-is-coming.html Example: User clicks on a button which updates the entity. It is a single transaction so one can see what is done in the code. After that several buttons can be disabled/enabled by the new state of the entity. This logic is usually scattered in the client components (buttons, ..) by overriding isEnabled()/isVisible() methods or setting specific visibility behavior. How I know what can user do as next? And which user can do that? Look at this article, point 5 http://www.infoq.com/articles/seven-fallacies-of-bpm This problem is solved by the explicitely creating processes instances and not handling them as something what emerges from ojects interactions. How it is solved in DCI? Or does DCI try to solve this as well? 3. Aren't you looking for a new developer? Thanks! And I'm waiting for a reply by some of the gurus, Trygve, Jim, Bill! But everyone can answer me as well:-) |
Posts: 6 / Nickname: cope / Registered: May 18, 2003 3:45 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
July 29, 2011 7:26 AM
|
> I will use word entity for a object which is a domain noun and is mapped to db. Entity class is a class of this object.
That could be why: > but no one is listening to me. I think that definition has little or nothing to do with what is described here. Thanks for your interest, anyhow. |
Posts: 1 / Nickname: jamesladd / Registered: December 4, 2011 6:58 AM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
December 4, 2011 1:12 PM
|
I read the article with great interest and I salute the authors for taking the time to write it. However, from the article:
"Object-oriented programming languages traditionally afford no way to capture collaborations between objects" to which I respond that a bad workman blames his tools! It is your choice to create and use objects for whatever you want to, including capturing the collaborations between objects. In fact, this is the heart of OO. When you model an object and have it interact with another you can choose to model that interaction as another object with a simply method invocation to carry out the interaction, or you can create no object and call a series of methods. A lot of this is captured in the OO principle Tell Don't Ask but most people just Ask, ignoring the benefits of Tell all together. For example: address.to_string() <- simplistic - why do you need a string? address.printOn(medium) <- OO, capturing the interaction. You can also take this further with an object that represents the process of taking an address and putting it onto medium. I wrote a lot about this in several posts on my blog about a technique I call East Oriented - http://jamesladdcode.com/?p=12 We have failed OO, it has not failed us. - James. |
Posts: 1 / Nickname: thorinp / Registered: January 6, 2012 9:07 PM
Re: The DCI Architecture: A New Vision of Object-Oriented Programming
January 7, 2012 3:19 AM
|
> I read the article with great interest and I salute the
> authors for taking the time to write it. However, from the > article: > > "Object-oriented programming languages traditionally > afford no way to capture collaborations between objects" > > to which I respond that a bad workman blames his tools! > > It is your choice to create and use objects for whatever > you want to, including capturing the collaborations > between objects. In fact, this is the heart of OO. When > you model an object and have it interact with another you > can choose to model that interaction as another object > with a simply method invocation to carry out the > interaction, or you can create no object and call a series > of methods. A lot of this is captured in the OO principle > Tell Don't Ask but most people just Ask, ignoring the > benefits of Tell all together. > > For example: > > address.to_string() <- simplistic - why do you need a > string? > address.printOn(medium) <- OO, capturing the interaction. > You can also take this further with an object that > represents the process of taking an address and putting it > onto medium. > > I wrote a lot about this in several posts on my blog about > a technique I call East Oriented - > http://jamesladdcode.com/?p=12 > > We have failed OO, it has not failed us. > > - James. Totally agree with this post. The assumption in the article seems to be that an 'object' has to represent something that can be stored in a database (> object boundaries already mean something else: they are loci of encapsulated domain knowledge, of the data <), which is a too narrow view of what objects are. If you have a high level action you want the application to perform, why not just use the Command Pattern, which encapsulates an action as an object? To prevent strong coupling between this Command object and the objects on which it operates, you can implement the Commmand object as a Composite Pattern, where a high level Command consists of series of lower level Commands. A high level Command could represent the transferral of money from one bank account to another. At a lower level, the Command object representing the actual money transfer will tell one Account object to lower its balance, and the other Account object to increase its balance. If DCI tries to solve the problem of not being able to capture interactions between 'objects', I think this problem has already been solved by the Command Pattern, using OO principles. |