Talk:ClarityOfTypes

From APIDesign

Jump to: navigation, search

JT said: The originally protected abstract methods are moved to Provider interface. Interface methods are public and this might seem like a contradiction to ClarityOfAccessModifiers. However, it is not. The instances of Provider interface are not accessible to clients of the API. They are hidden and only useful for the create factory method that turns them into NonMixed instances. As such they are single meaning methods with only one message: implement me, don't call me!. Their clarity is kept.

OK the above is totally confusing. The Provider interface is a public interface residing within a public class (which itself I experience as confusing, but that's a stylistic issue). I can implement this interface and throw it around at will. For that reason, instances of the interface are accessible to clients of the API. For the same reason, they say to me- implement me and do whatever you want with me, including call me. All of this is of course just the opposite of what the books says.

--parren(?)

Actually you cannot implement this interface and throw it around at will unless you create your own API. And the question is whether creating an API that makes the Provider interface accessible to others is good idea. As far as I can tell it might, but usually it is not.

Without creating own API, you can only implement the Provider interface but there is no way to sneak it to others. Nobody (without a special contact with your code) can call the Provider interface, as there is no way to get a reference to it. As such the Provider (in context of its API) says only implement me, you have no chance to call me anyway.

--JaroslavTulach 04:51, 10 April 2009 (UTC)

I have just created ImplementOnlyInterface page to cover this discussion. Feel free to tweak it a bit.

--JaroslavTulach 16:59, 12 April 2009 (UTC)

Personal tools
buy