What are objects in object-oriented programming?
- Objects are entities with behavior.
- Objects may hold information, perhaps as
properties/attributes.
- Objects are defined by how they interact with
other objects (its "public" methods).
- Objects are NOT defined by how they are
constructed internally nor by what information it holds.
- A program is a system of interacting objects.
- Objects don't necessarily have names.
What are classes?
- A class is a description of a type of object.
- Classes are used to create (construct) objects.
- One class can be used to create many objects.
- Classes always have a name.
- Classes show how objects are implemented.
What are Methods
- Methods are the things an object does.
- An object may have methods that only it can
access (private methods).
- Methods can take values as input and return a value as
output.
What are Properties (Attributes)?
- Properties are what an object knows or
remembers.
- Properties are never directly exposed to other
objects:
- To see the value of a property, a method is
needed.
- To set the value of a property, a method is
needed.
- Properties are often described as holding the
"state" of the objects.
- The object's class will describe the existence
of a property, but usually not the property' value.
- Different objects of the same class are
distiguished by differences in the value of their properties.
- Properties are often also called "attributes" or "instance
variables".
What are Variables?
- Variables are abstract references to
values. They are used because in general, one is concerned more
with the existence of a value and less with the actual content of that
value.
- Values may be numbers, characters, true/false
logicals (booleans), arrays, or other objects.
- Two different variables may reference the same object.
|