Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to explain an object?

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:

  • Access Levels
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction
  • Interfaces
like image 232
Robert MacLean Avatar asked Jun 15 '09 09:06

Robert MacLean


People also ask

How do you explain object in a sentence?

Generally, we use the word 'object' to talk about the thing/person that the action is done to. Or, the one who receives the action. A direct object is a noun or pronoun that receives the action of a verb in a sentence. Usually, it answers the questions what? or whom? about the verb.

What is object explain with examples?

An object is a noun (or pronoun) that is acted upon by a verb or a preposition. There are three kinds of object: Direct Object (e.g., I know him.) Indirect Object (e.g., Give her the prize.) Object of a Preposition (e.g., Sit with them.)

How do you describe physical objects?

Objects can be described in terms of the materials they are made of and their physical properties. Describe objects in terms of color, size, shape, weight, texture, flexibility, strength and the types of materials in the object.


2 Answers

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!

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.

like image 85
Joonas Pulakka Avatar answered Sep 20 '22 13:09

Joonas Pulakka


I like the original metaphor used by Alan Kay, who coined "object-oriented programming": Objects are like cells in a body. They are each programmed with their own behaviors and communicate by passing messages to one another, which they again respond to with their own internally defined behavior. No one cell knows what's inside another — they just know how to handle their own tasks and communicate with each other.

like image 36
Chuck Avatar answered Sep 20 '22 13:09

Chuck