What's the best way to define the words “class” and “object” to someone who hasn't used them?

前端 未结 29 658
情话喂你
情话喂你 2020-12-13 05:11

My neighbor is taking \"Intro to Java\", and asked me to help explain a few of the first-day concepts. I realized that since I do this everyday, I don\'t have the beginner\

相关标签:
29条回答
  • 2020-12-13 05:41

    If your neighbor is into classical philosophy, classes are Plato's Forms and objects are the things we see everyday that are based on the Forms.

    0 讨论(0)
  • 2020-12-13 05:41

    Class can be defined as the blue print or template which defines attributes,actions,states for the entity and Object would be the one which would be implementation for the entity.

    0 讨论(0)
  • 2020-12-13 05:42

    One of the examples I use during my java courses is the Human class.

    Everyone reading this is a Human (I least I hope so !), we all have our differences our resemblances but at the end we're all Human (After all).

    Each Human (known as an instance or object) has specific characteristics such as the eyes color or the voice which are the fields (you called that variables, but the right name would be fields). But the values are different from an Human instance to another.

    There is also a common knowledge, shared with the humanity, principles like the "Pythagorean theorem". This knowledge is common, it can be interpreted as a static field (I know it's an exaggeration) which means that this knowledge is not only contained in one human but in the humanity.

    Every Human can do things such as walking, speaking etc. this is known as method, walking is the same for everyone, but when I walk, not everyone walk. The act of walking only affects the Human instance which does this, but still it's defined by the Human class


    If you want to get deeper in OOP, Teaching OOP to non-programmers

    0 讨论(0)
  • 2020-12-13 05:46

    If and only if he is familiar with Plato's Theory of Forms, you can make an analogy where classes are like Plato's forms and objects are like Plato's real world objects.

    See this post for a full description.

    0 讨论(0)
  • 2020-12-13 05:47

    Class: Girl

    Object : that girl, this girl, my girl...umm maybe not.

    Yea all girls should have the properties of a Girl (class in this case).

    0 讨论(0)
  • 2020-12-13 05:47

    class: custom variable type

    object: a variable, whose type is custom defined (if you don't count the built-in ones)

    0 讨论(0)
提交回复
热议问题