Quick Index
Index
Overview


We'll briefly touch on primitive types (prims) and then the remainder of the discussion will be about object types.

Primitive Type Concept


The following examples apply to most object languages.

What are prims
Many object languages have "primitive types".
Primtive data is generally integers, doubles, booleans, strings, etc.
Example Usage
Here is a simple example using primitive types.
a = 10;
b = 5;
sum = a + b;
No Messages
We can not send messages to primitives.

If you have not learned about messages yet -- no worries, you will soon.
a = 10;
a.print(); //ERROR (cannot send message)
No 'null' Assignment
NOTE WELL - This applies to statically typed langues only.

We cannot assign null to primitive variables.

If you have not learned about 'null' yet -- no worries, you will soon.
//Primitive variable a
int a;
a = null; //ERROR


Object Type Idea


An object system is composed of "objects".

Each of these objects have a type or an object type.

Objects


Think of objects as instances, things, items, nouns, etc.

Examples: a Person, a Ball, a Rectangle.

Another term we will use for "object" interchangeably with "instance".

Note how we 'Objects' is plural. We can have zero to many objects.

Here we have a simple collection of persons.

Each "person" is one object. So we have nine objects.
😊
Yang
😇
Sally
😔
Kofi
🙂
Jiao
🤭
Yawo
😀
Bob
😁
Mary
😃
Khawla
🤫
Zada
Here we have a collection of balls.

Each "ball" is one object.
Here we have a collection of rectangles.

Each "rectangle" is one object.

Object Type Concept


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



Examples


Use class interchangeably with type.

Example #1

Think of five "classes" (object types). Description

Think of:
Tips


Hints

Solution


Example #2

Given a class (object type) called Student.
Think of five possible instances (objects) of class/type Student. Description


For simplicity let's just use first name to describe these Student objects. Tips

Hints

Solution



Example #2

We may define a Lake to have a name, location, depth and size. Three examples of Lakes are: "Lake Superior", "Parker's Lake", "Medicine Lake".

Which are the class(es) and which are the object(s) ? Description


Classes are definitions.
Objects are instances or real occurrences. Tips


Hints

Solution


Example #3

Think of a blank college application. The application is like a class. It has been designed with blank fields to capture information. For this example, assume the original blank college application sits in the admissions office. How would we use the application? Description

List the steps that an admissions person might take. Tips

Hints

Solution