What's the difference between public interfaces and published interfaces in Java? [closed]

痞子三分冷 提交于 2019-12-13 15:12:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!