Useless interfaces

后端 未结 25 1578
南笙
南笙 2020-12-14 01:42

Why would you ever use an interface if you are only going to have one implementation of it?

25条回答
  •  独厮守ぢ
    2020-12-14 02:30

    To promote loose coupling, it is considered better design to rely on an abstract dependency than tying yourself to a concrete class.

    One example of where this practice is especially useful is Spring's proxy-based remoting approach., where your single implementation resides in a different JVM.

提交回复
热议问题