> > 1. (String)context.get( "name.key" );
> > 2. ((NameContext)context).getName();

> In what way does (2) have stronger coupling? Since there is logical
> equivalence between having a "name.key" entry and a NameContext
> interface:

There are two flaws with the second approach.  The first is that in the
second case, you force me to have a upon a NameContext, which I couldn't
care less about, in the case of that example.

More importantly, the second example makes a mistake of tying IMPLEMENTATION
of the Context into the INTERFACE.  I have no problem with:

  String s = ((T)context.get("urn:foo:bar")).f()

where we acquire a reference to a object of type T from the context, convert
the reference, and invoke the operation.  In that case, even if the context
returns itself, we have decoupled the caller from knowing that information.
We have eliminated an implementation dependency.

Is this clearer?  The second issue is the far more serious one.

        --- Noel


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to