Internal interfaces separated from external API as in Eclipse
See also an Eclipse Corner Article (that is apparently "deprecated" without any given reason).
To separate API methods that should be callable by external code from internal methods you can use a pattern that is used at many places in the Eclipse framework:
<uml> !include kit-blue.iuml !include sans-serif.iuml interface YourInterface {
externalAPIMethod()
} interface InternalYourInterface {
internalMethod()
} YourInterface <|-- InternalYourInterface class YourInterfaceImpl {
externalAPIMethod() internalMethod()
} InternalYourInterface <|-- YourInterfaceImpl </uml>
The important part of this simple pattern is:
- if you provide objects of your implementation class
YourInterfaceImplto external code, then type it only using the API interfaceYourInterface - only type objects of your implementation class
YourInterfaceImplwith the internal interfaceInternalYourInterfaceif you want the code to use the internal methods
Note: It is easy for external code to simply cast an object typed YourInterface to InternalYourInterface, but the necessity to perform such a explicit cast is exactly what this pattern gives you. Not more.