Re: creaping coupling......

From: Robert C. Martin (unclebob_at_objectmentor.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 08:48:44 -0600

On Fri, 25 Feb 2005 18:44:29 +0100, Laurent Bossavit
<laurent@dontspambossavit.com> wrote:

>It's what happens after the first pass that's interesting. Experimenting
>with the Java compiler will reveal that if you make some trivial change
>to the client code in Main, and ask the compiler to recompile *just*
>Main.java, the corresponding source file, then the compiler will read
>the compiled bytecode for IWriteable, CPipe, and CPipeWriter, which Main
>*directly* depends on. (It will also recompile these classes if it
>doesn't find the bytecode for them.) But the Java compiler will *not*
>access, at all, the files for IElement and Element. Changes do not
>propagate unnecessarily in Java - there isn't the physical coupling
>problem that happens in C++ unless you take steps to prevent it.

Isn't it interesting that either IElement.java or IElement.class
*must* be present when you compile main; and yet in the C++ version
IElement.h need not be present to compile main.cpp. In that sense,
C++ has managed to decouple more than Java.

Of course once you compile main in java, it's ready to run. Compiling
main.cpp in C++ does not make it ready to run because you haven't
linked it. Linking it *will* require that IElement be compiled.

So the issue is a temporal one. The java compiler needs IElement
source (or binary) code a bit sooner than C++ does. I suppose that
difference in temporal coupling could make a difference in some cases.
On the other hand, the efficiency of java compilation is probably
worth it.

-----
Robert C. Martin (Uncle Bob) | email: unclebob@objectmentor.com
Object Mentor Inc. | blog: www.butunclebob.com
The Agile Transition Experts | web: www.objectmentor.com
800-338-6716

"The aim of science is not to open the door to infinite wisdom,
 but to set a limit to infinite error."
    -- Bertolt Brecht, Life of Galileo



Relevant Pages