无用的接口 [英] Useless interfaces
本文介绍了无用的接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果您只打算实现一个接口,为什么还要使用它?
Why would you ever use an interface if you are only going to have one implementation of it?
推荐答案
如果我知道只有一个实现,我就不会创建接口.这属于 IMO 的 YAGNI.
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...)
这篇关于无用的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文