This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
i am having a class which is delegating methods to another class, which implements an interface. i thought about making the delegation explicit by implementing the interface of the delegating class.
i am having following code:
now my idea is to explicitly delegate by having the wrapper A implement the interface, too:
in my view it is alright because all methods are making sense in the view of A and therefore should not be confusing for the user. on the other hand i am a bit unsure, because i rarely see this way to show the delegation in the type declaration.
by the way: it is not applicable to inline B to A, because otherwise A would be too big.
This looks a lot like the Decorator pattern to me. I use that a lot. In particular, I always add an "implements" if a decorating class does actually provide the methods of the interface (with the same signatures), so that it in turn may be decorated if needed.