Interfaces (interface/abstract class) are not abstractions?

后端 未结 4 1859
情书的邮戳
情书的邮戳 2021-01-02 04:43

Of late, I have been reading posts which talks about the supposed wrong notion that interfaces are abstractions. One such post is http://blog.ploeh.dk/2010/12/02/InterfacesA

4条回答
  •  [愿得一人]
    2021-01-02 04:55

    Programming to an interface instead of an implementation is more about using data abstraction and encapsulation.

    When we say "interface" in terms of programming to an interface. That kind of interface means the external facing methods and properties of a class. It doesn't have to be a language level interface. (The keyword interface.)

    You should be striving to make sure that your code is not dependent on the internal details of other classes.

提交回复
热议问题