Index

Object Type


Now let's look at object type. This section is hot 🔥.

Person Type


😊
Yang
😇
Sally
😔
Kofi
🙂
Jiao
🤭
Yawo
😀
Bob
😁
Mary
😃
Khawla
🤫
Zada
Recall our set of nine persons (objects).

Can we generalize all of these into one general object type?


Person
😊
firstName
Let's define a simple object type for Person and give it one property:

firstName -- The first name of the specific person instance/object

We also use the term variable for property.
The terms general and specific are used a lot in object coding.


Ball Type


Recall our collection of many balls (objects).

Can we generalize all of these into one general object type?


Let's define an object type for Ball and give it these properties:


Note that for real ball objects, "r" and "color" will vary. They are variables. We'll learn more about these later.
We might also call this type "Sphere"


Rectangle Type


Recall our collection of many rectangles (objects).

Can we generalize all of these into one general object type?


Let's define an object type for Rectangle and give it these properties:


Note that for real rectangle objects, "width" and "height" will vary. They are variables. We'll learn more about these later.


Rectangle Type vs Rectangle Objects


Here is another perspective.

We have one "Rectangle type".

We have many rectangle objects.


Properties


In the examples above we used the term "property" to define things like "width" and "height" of a Rectangle type.

There are many different terms that we will use interchangeably with "property":


These terms tend to have relatively "loose" meanings in object coding. Therefore, do not worry about their strict meaning, but rather simply understand that they are used to help define object types like in our examples.

Object Type Summary


We generalize a collection of many similar objects into one general type (or class).

The word "general" is key in object thinking. 🔥

Summary Table:

ConceptAlso CalledCountQuick Description
TypeClass (Next Chapter)OneA single definition (e.g. "Person")
ObjectInstanceZero to manyActual person objects. For example: "Zada", "Yang", "Yawo", "Bob", ...
PropertyField, Varibable, or AttributeZero to many for a given typeAspects of an object like "width" and "height" (e.g. for a Rectangle type)


You can define any object type (class) you like. Just a few examples here to give you an idea: Airplane, Baby, Bird, Car, City, College, CollegeApplication, Computer, Country, House, Lake, Person, Player, Rectangle, Road, Student, Team, Train, etc.

Another way to look at it is to think of a general type (class) is like a "blueprint" or "plan". We have one "blueprint" idea for say a bicycle that can be used to construct many actual bicycles. Some parts of the individual bikes may vary (e.g. color), but they all follow the pattern of the blueprint.

Object Type References