定义接口? [英] Defining Interface ?

查看:77
本文介绍了定义接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以这样说,编程中Object的实现部分和数据部分的分离是接口。

Can I say that, "Separation of implementation part and data part of Object in programming is Interface".

推荐答案

不 - 不是真的。



界面就像是合约或承诺。实现该接口的任何代码都必须履行合同或承诺。这允许我们将代码分成事物可以做什么而不是每件事情究竟是什么。



例如,方向盘和踏板布局汽车是一种界面。这使您可以驾驶任何实现此界面的汽车,而无需为标致,捷豹,福特等学习单独的规则。同样的原则适用于软件。
No - not really.

An interface is like a contract or promise. Any code that implements that interface must fulfil the contract or promise. This allows us to separate code into "what a thing can do" rather than "what exactly each thing is".

For example, the steering wheel and pedal lay out of a car is a type of interface. This allows you to drive any car that implements this interface without having to learn separate rules for Peugeot, Jaguar, Ford etc. This same principle applies in software.


这篇关于定义接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆