更新时间:2023-11-06 10:18:04
类比1 :很像美国航天飞机,俄罗斯联盟号航天器和中国神舟5号都可以停靠国际空间站,因为它们实现了相同的对接界面。 (这只是一个例子 - 我不知道在现实生活中是否真实,但是为了举个例子,我们暂停我们的怀疑)
类比2 :像您可以将各种电脑显示器插入家用电脑。您可以将壁挂式电视插入其中,一个旧的CRT(厚型),一个20平面屏幕或盲文机,让盲人通过触摸查看。这些各种/不同设备和您的因为他们都同意接口标准。
C#界面的详细信息 -
使用C#/ OOP接口,您正在做同样的事情,但看不见/虚拟世界。
您正确的标准化,而且可变性,可扩展性,可扩展性,可维护性,可重用性,可测试性和电源。 >
(使用软件界面越多,这些嗡嗡声就越能被理解,并且总是考虑现实世界中的接口,因为他们已经做了我们亲爱的。)
Why do we use Interface?
Is it only for Standardization?
Analogy 1: Much like the US space shuttle, Russian Soyuz spacecraft and Chinese Shenzhou 5 can all dock to the International Space Station, because they implement the same docking interface. (This is just an example - I don't know if it's true in real life however let's suspend our disbelief for the sake of an example)
Analogy 2: Like you can plug various computer monitors into your home computer. You can plug a wall-size TV into it, an old CRT (the thick kind), a 20" flat screen, or a braille machine for the blind to "see" by touch. There's compatibility among these various/different devices and your computer because they all agree on interface standards.
Details of C# interfaces -- With C#/OOP interfaces you're doing the same kind of thing but in the unseen/virtual world.
You're correct about standardization, but also flexibility, scalability, extensibility, maintainability, reusability, testability and power.
(The more you use software interfaces the more these "buzz words" will be understood. And always consider interfaces in the real world because they have done us equally well.)