Useless interfaces

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

    If I knew for a fact that there would only ever be one implementation I wouldn't create an interface. This falls under YAGNI, IMO.

    (Of course, it's rare that I know anything about the future for a fact...)

提交回复
热议问题