Again, your response is a caricature of someone stuck in a class paradigm |
I'm perfectly ok with doing OOP without classes - the example used classes/static interfaces just because this is a C++ forum. Also, I've been using most of the techniques described in the paper by Reenskaug and Coplien for some time, using the Scala language.
Whatever you say, this whole DCI thing looks to me like a solution seeking a problem. I'm 99% sure no-one will use that DCI concept 5-10 years from now. Why? Because of the following fundamental things:
1. It is extremely hard to explain the essence of DCI to a programmer while going with him by lift from ground to the 10th floor. It is easy to explain the underlying concepts. But DCI as a whole is somehow blurry.
2. The DCI is composed from many other very simple concepts like mixins or multiple dispatch and brings little additional value to what is currently used and supported (most OOP languages have mixins, traits, roles, etc, so they supported DCI almost directly for quite a long time). For me this perfectly sits in the OOP world. This is *not* a new paradigm. This is incremental improvement, one of many possible design patterns.
3. Successfull new design patterns and paradigms are *simple* in essence, and usually discovered and not invented by some theoretists by combining many simple patterns into one complex system. Think: lambda expressions, private state encapsulation, factory methods, virtual dispatch. Things that are often so different that they require new language constructs. And that are so influential that good number of languages implements them as core features.
BTW: It very much resembles another failed "wish to be" paradigm: AOP. Some AOP techniques are used in practice, but almost no-one builds systems the AOP way. So this is a design pattern, not a paradigm shift.
Update:
Back to the original question - if we are not talking C++, I could make the SpellCheck class a trait/role (in Ruby or Scala) and mix it into any TextBuffer that would need to be spellchecked. But that doesn't really solve any real problem - the coupling still exists. The SpellCheck still has to know how to get the text and how to get the valid words from the dictionary. So essentially it still has to rely on some fixed interface, even if it is not given explicitly in the code. If this interface changes, you have to fix the other components of the system, otherwise you won't be able to mix that "spellchecking role" in - it will fail either at compile time (Scala) or run time (Ruby). There is no benefit in better cohesion or coupling. There might be a slight programming "convenience" benefit, because you can actually write a "TextBuffer with SpellCheck" type and you have all the methods/services in one point, so in case of Scala, the IDE can give you a nice list of methods, etc. So it is easier to use, code is probably more readable - you can also pass one object with additional spellchecking role instead of two objects. But calling it a new paradigm is IMHO ridiculous.