Maybe DCI is nothing more than the "old" OOP applied with more experience, giving the practitioner an eagle-eyed view or something? |
Like Schroedinger's cat.
Then you're absolutely right that there's no easy way for attain that level of proficiency. |
I don't think anyone would confuse what I said for meaning that it would be easy.
But as a paradigm, doesn't DCI have a set of concepts or rules, that you can exemplify in a simple program? |
It's kind of like asking: Don't relational databases have a set of concepts or rules that you can exemplify in a simple program? Maybe, if you're already steeped in relational algebra. But it's very unlikely that C++ programmers would have had the exposure. It is in fact much easier with JavaScript programmers, and it's pretty clean in Ruby.
I tell people who want to learn "Restricted OO" to start in Smalltalk; it's too easy to develop bad habits when starting in C++. I would tell people who want to learn "Full OO," as Reenskaug calls it, to start either with Trygve's BabyUML environment or with Ruby. But, still, before that — do I have to say it again? — there is some booking-it to be done. Think of the analogy to relational databases.
I could show you an SQL program that illustrates how to use a database, but that doesn't mean you would understand databases. Similarly, I could show you the Context for a DCI program to do X, but that doesn't mean you'd understand DCI. My experience is that there is a lot of danger of trying to teach a new paradigm by incrementally building on an existing one. That's what leads people to say things like:
That fixes the role of each object ('he' turns into a subject -> the active part) and thus opens a new world. That is what I call object oriented. |
Let's start with that as a touchstone. Let's say that I want to display a shape on a window. I have an inheritance hierarchy of window classes and an inheritance hierarchy of shapes. Where does the
draw
method go, and what are its arguments?
There is no clean way to do it in C++: each implementation has serious problems with coupling and cohesion. That's what led Cargill and I (pretty much simultaneously) to invent what today is called the Visitor pattern in C++. (It turns out that it was already there in the Smalltalk-80 image.) That and Singleton are the only patterns that Erich Gamma said he would pull from the book if they were to do it again — mainly because the only people who understand Visitor are consultants who are trying to impress their clients.
But enough of C++. Back to our story. What is the right way to write
draw
? In CLOS, one writes code that looks similar to a collection of overloaded C++ functions:
1 2 3 4
|
draw(Circle c, TiledWindow w) ....
draw(Rectangle r, TiledWindow w) ....
draw(Circle c, PixelatedWindow w) ....
draw(Triangle t, PixelatedWindow w) ....
|
The thing is that these method bindings take place at run time rather than following the C++ of compile-time overloading.
Is that object-oriented? To me, it is. It certainly doesn't fit the only definition for OO I've seen in this thread:
That fixes the role of each object ('he' turns into a subject -> the active part) and thus opens a new world. That is what I call object oriented. |
DCI moves from C++ in the direction of multi-methods, through CLOS, and on. It is difficult to reason about these concepts in terms of what you know.
But all of this is written elsewhere. You'll find the pointers to it above. I'd encourage you to invest the time looking at it.