locked
Problems inheriting interfaces RRS feed

  • Question

  • Hello everyone.  I have a question that I'm somewhat surprised that I have to ask.  I'm not really sure why I'm having this problem but here it is.

    I have 3 libraries (names are for example only); LibAgent, LibBCFacade, LibBC

    I'm trying to prevent calls from being made directly to LibBC from LibAgent, however, LibAgent is designed to represent LibBC, so imagine the following:

    LibBC:

    IWorkflowComponent1
    {
       void DoSomething();
    }

    IWorkflowComponent2
    {
       void DoSomethingElse();
    }

    LibFacade:

    IBC : IWorflowComponent1, IWorkflowComponent2 { }

    LibAgent:

    IAgent : IBC {}

    class Agent : IAgent
    {
         void DoSomething()
        {
             // implementation
         }

         void DoSomethingElse()
        {
             // implementation
         }
    }

    So given this I'm assuming there in nothing too special going on, at least not from a code perspective, however, I am having a problem with Project references.

    IDEALLY I do not want LibAgent to reference LibBC directly.  I do not want consumers in LibAgent to call LibBC, I want them to go through LibFacade.  And herein lies my problem.

    If I don't reference LibBC from my LibAgent project I get a compile error - something about reference not available - on the IAgent definition.  This doesn't make sense to me (well there is a small part of me that thinks that this is an interface issue and the way they are handled by the compiler).  If LibAgent references LibFacade and LibFacade reference LibBC then LibAgent should be able to 'see' LibBC (at least from the perspective of the interfaces that are being inherited).

    So IAgent should be able to be implemented by class Agent without a reference to LibBC since it inherits from IBC which is defined in LibFacade (which it has a reference to) even though IBC inherits from LibBC (LibFacade has a reference to LibBC).

    Phew...that is just hard to type.  It is a lot easier to see in the IDE and I'm happy to send a mock solution to anyone willing to entertain me.

    Thanks,
    Frank
    Friday, October 23, 2009 4:22 AM

All replies

  • Greetings

    Check your UML designs i.e. class diagrams.

    Kindly recheck the design.

    Take Care

    PL
    Helping People To Solve Technical Problems
    Friday, October 23, 2009 4:49 AM