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

前端 未结 29 656
情话喂你
情话喂你 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:38

    An Object is a group of related data and functionality. What the group of data and functionality will consist of is defined in the class. Class is the design or specification of the object.

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

    I would highly recommend telling him/her to buy a copy of a book called The Object-Oriented Thought Process by Matt Weisfeld. It's a really good conceptual introduction to OO. I've lent out my copy to a few people who were just getting into OO and they really liked it.

    0 讨论(0)
  • 2020-12-13 05:39
    Class: Human being
    Object : Man, Woman 
    
    Class : Fruit 
    Object : Apple, Banana, Mango ...
    
    Class : Mobile Phone
    Object : Apple , Samsung , LG ...
    
    Class : Food
    Object : Pizza, Rice ....
    
    0 讨论(0)
  • 2020-12-13 05:40

    A class and some class instances:

    Courtesy of wikipedia

    (public domain image hosted by wikipedia)

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

    If they are learning to program OO have them use BlueJ. They should get the differences after walking through the first tutorial.

    You define the classes and when you instantiate them they actually appear at the bottom of the GUI at which point you can call methods on them.

    It really helps get the point through better than any analogy you want to try. Even if you nail the analogy, it doesn't translate into code for someone who hasn't learned OO yet (even though for all of us it seems really natural and all these descriptions make great sense.)

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

    I always define them as blueprint and product.

    A blueprint describes the complete product in every detail, the product is the result that comes out of the machine.

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