问题
I've read these two pages
- http://martinfowler.com/ieeeSoftware/published.pdf
- http://lambda-the-ultimate.org/node/1400
but I still don't get the difference between a published and public method. An example in Java would be helpful. Thanks in advance.
回答1:
public
Public interfaces written in Java:
interface MyInterface { ... }
public interface MyInterface { ... }
class MyClass() {
void anotherInterface() { ... }
public void someOtherInterface() { ... }
}
All of them are public because they are not only available for internal objects.
published
The status of published interface is not part of the Java language, it is part of what some may call application architecture. It is in a higher level of abstraction.
Now, the relationship between the two:
- Every published interface is a public interface.
- Not every public interface is a published interface.
Note: The concept does not apply literally to only Java interfaces, it could also be class, methods etc.
To dig deeper: Public versus Published Interfaces
来源:https://stackoverflow.com/questions/20832506/whats-the-difference-between-public-interfaces-and-published-interfaces-in-java