Useless interfaces

后端 未结 25 1581
南笙
南笙 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:23

    To separate the API from the implementation, which is often a good programming practice. It will help with readability, if nothing else. It will also allow someone using your code in the future to provide an alternate implementation of the interface if they so desire.

提交回复
热议问题