如何解释一个对象? [英] How to explain an object?

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

问题描述

我想到这一点已经有好几年了,但是我很快就在训练一些真正的初中生,需要向不知道它是什么的人解释一个对象是什么.

It's been years since I thought of this, but I am training some real juniors soon and need to explain what an object is to someone who doesn't know what it is.

根据您在现实世界中使用的内容,我应该着重解释的对象的关键点是什么.例如:

Based on what you use in the real world, what are the key points of objects that I should focus on explaining. For example:

  • 访问级别
  • 继承
  • 封装
  • 多态
  • 抽象
  • 接口

推荐答案

当我学习OOP时,我对所有这些汽车/动物/其他"比喻感到困惑.他们根本没有帮助我.然后有人说一个类/对象只是一组变量(类成员)和处理它们的函数(方法)-实际上,这是正确的.就这么简单!

Back when I was learning OOP, I was puzzled by all these "car / animal / whatever" metaphors. They didn't help me at all. Then someone said that a class/object is just a set of variables (class members) and functions to deal with them (methods) - which is actually true. It was that simple!

使用所有这些流行的隐喻只会误导人们,恕我直言.汽车与OOP没有太多共同点.很容易理解这些隐喻何时,当您已经知道它们的含义时,却尝试着从它们开始……不.

Using all these popular metaphors is just misleading people, IMHO. Cars don't have that much in common with OOP. It's easy to understand these metaphors when you already know what they mean, but trying to begin with them... no.

这篇关于如何解释一个对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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