Skip to Content
avatar image
Former Member

Design question: Interface Controller vs. component controller

Hello,

I have a component A. This component has a component controller (compController) and an interface controller (intController).

Component controller has method compMethod()

Interface controller has method intMethod()

- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)

- Am i allowed to call compMethod from intController or is this bad design?

- Am i allowed to subscribe compController to event in intController or is this bad design?

Kind regards,

Joren

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 27, 2006 at 08:58 AM

    Joren,

    <i>- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)</i>

    Yes, it is possible, however this is bad design though it is used in tutorial 😉

    See, that assumes that method in interface controller has some logic. However, intent of interface controller is only to expose functionality available in other controllers (component controller and custom controllers). There are some comments that in further WD versions interface controller will be in fact interface (in Java sence), so prepare early -- do not put logic in interface controller and simplify migration of components in future.

    <i>- Am i allowed to call compMethod from intController or is this bad design?</i>

    Doch! You should use this approach, this is correct and recommended design.

    <i>- Am i allowed to subscribe compController to event in intController or is this bad design?</i>

    Also possible, but smells like the first one. Again, interface is exposing functionality, do not overload it with implementation.

    Valery Silaev

    SaM Solutions

    http://www.sam-solutions.net

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2006 at 10:52 AM

    Hi Joren,

    like Valery already pointed out, we recommend not to implement any logic in the component interface controller but only implement methods used for delegating logic to the component controller. This is based on the fact, that the component interface controller will be implemented by the component controller in the the next major SAP NetWeaver Release. This means that it will not have its own Java class like in NW04 and NW04s. To simplify migration the interface controller code should be as slim as possible by applying the delegation principle.

    You wrote:

    <i>- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)</i>

    Yes, my (very old) tutorial on serverside eventing exposes a public method <i>fireEvent()</i> which is invoked by the component controller. In early versions of NW04 the wdFireEventInnerEvent() method was not exposed in the IPublic-API of the component interface controller but only in the IPrivate-API. Therefore an additional method fireEvent() must be defined to fire the event from another controller. As a negative side effect, this public fireEvent() method is also exposed by the IExternal-API of the component interface controller so that the event can be fired from outside (by the Embedder component) which is not desired in most cases.

    Meanwhile the wdFire<event name>() method is exposed by the IPublic-API of the component interface controller, so that the public method fire<Event name>() is no longer needed.

    I will update the tutorial in this respect so that it again propagates best practices.

    Regards, Bertram

    Add comment
    10|10000 characters needed characters exceeded