Useless interfaces

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

    It can be very good practice to set up an interface as a spec to code your class to.

    If you determine the public methods/functionality that your interface will have you can lock that in place. Then it becomes much easier to code a class when you have a clear functionality in mind for it.

    I feel it is more important to make writing good code easier than keep the code base clean.

提交回复
热议问题