Re: graph of behavior - was Re: State vs. Data (was Re: Fans of Template Method with protected variable?)

From: Mark Nicholls (Nicholls.Mark_at_mtvne.com)
Date: 09/09/04


Date: 9 Sep 2004 07:14:40 -0700

expanded from Mr Martin....

> package a;
>
> public class A
> {
> public void f(IB b)
> {
> b.g();
> }
> }
>
> interface IB
> {
> void g();
> }
>
> package b;
>
> public class B implements a.IB
> {
> public void g()
> {
> ...
> }
> }
>
> Thus [a]----->[b] was changed to:
> [a]<-----[b] without changing the flow of control.
>

There is something even more fundamentally flawed with this.

In the example in you book you show 3 layers so in fact

interface IB
{
   void g();
}

should read

interface IB
{
   void g(IC c);
}

but where is the definition of the interface IC, by DIP it should be
in the client of the implementations of C i.e. package B so A must
reference B - *****contradiction****** A now depends on the
implementation of the interface IB

I belief that is a general ***proof*** that DIP is self contradictory
in systems with more than 3 layers (and interfaces that operate on
'lower' levels, as in your example).

not only does it contradict DIP it also usually impossible as it
creates a circular reference between A and B.



Relevant Pages

  • Re: Abstract interfaces and classes - Urgent Help
    ... public abstract interface Interface_A: _Interface_B, ... public abstract new void method1; ... public virtual new void method3() ... Public class _MyClass: OCXReference.InterfaceClass ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interface Delegation or ??
    ... otherwise for public classes use a public interface. ... I don't think the visibility of the interface makes much ... practical difference if the interface is only implemented in package ... public class NewClass implements HiddenInterface { ...
    (comp.lang.java.programmer)
  • Re: Interface Delegation or ??
    ... It makes a difference to the visibility of the interface type, which is the reason one mucks with visibility. ... interfaces are implemented only in package visible classes. ... No previous implementation of the interface can have been passed to a public method in a public class, since none of the type or its subtypes were publicly visible. ...
    (comp.lang.java.programmer)
  • Re: Protected and package in iterface
    ... Why did the people writing the Java specs decide that an interface ... package, and internally you want your classes to implement some ... or Warranteeable, but I can access the service and warrantee methods. ... public static void main{ ...
    (comp.lang.java.programmer)
  • Re: graph of behavior - was Re: State vs. Data (was Re: Fans of Template Method with protected varia
    ... > public void f ... > public class B ... > In this case package a depends upon package b. ... > interface IB ...
    (comp.object)