继承是一个“is-a”的过程。关系;总结“界面”的好方法是什么?关系? ——总结其他关系?
标题:继承是一种“is-a”关系;总结“接口”关系的好方法是什么?
另外,我认为拥有一个简单关系的存储库来帮助人们正确看待事物会很好。我对编程相当陌生,所以我不确定是否真的有足够的“关系”来保证这个愿望——但如果有的话,这可能是一个很好的起点。
- 继承=“is-a”
- 组合=“has-a”
- 接口实现=?...
Title: inheritance is an 'is-a' relationship; What is a good way to summarize the 'interface' relationship?
Also, I think it would be nice to have a repository of simple relationships to help people put things in perspective. I'm fairly new to programming so I'm not sure if there's really enough 'relationships' to warrant this aspiration-- but if there is, this may be a good place to start.
- inheritance = "is-a"
- composition = "has-a"
- interface implementation = ?...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
接口实现 = "can-do"
接口通常代表您可以在类中实现的一种能力,例如在 .NET 中,
IEnumerable
接口用于您可以枚举的类,并且IComparable
用于可以比较的类。Interface implementation = "can-do"
An interface usually represents one ability that you can implement in a class, for example in .NET the
IEnumerable
interface is used for classes that you can enumerate, andIComparable
for classes that you can compare.为什么不只是“实现一个”?我想我不确定你在开车的目的是什么。
why not just "implements a"? guess I'm not sure what you're driving at.
您的谓词 is-a 和 has-a 描述了不同类型之间的结构关系。从这个意义上说,接口也应该有 is-a。
然而,还有更多可能的分类法和更多的 oop 关键概念:
Your predicates is-a and has-a describe the structural relation between different types. In that sense, an interface should also get the is-a.
However, there are more possible taxonomies and also more oop key concepts:
也许是“as-a”或“like-a”:暗示它具有某些属性/能力,但并非直接派生自。
Maybe "as-a" or "like-a": Implying that it has some properties/abilities but isn't directly derived from.
界面是一种“适合”的关系。
想想墙上的电源插座。这是您与电网的接口。您可能有许多共享此类接口的对象(即它们都“适合”套接字)。
其他国家有不同的界面,以及将“适合”这些特定方案的不同对象集。
Interface is a "fits-into" relationship.
Think about the electrical socket in your wall. That is your interface to the electrical grid. You may have many objects that share such an interface (i.e. they all "fit-into" the socket).
Other countries have different interfaces, along with differenct sets of objects which will "fit-into" those particular schemes.