Object Oriented Programming is about writing code using constructs called objects. We can say that everything can be called an object if we stick to the accepted definition by the Language Academia1. To understand the concept of object in Computer Programming we may start with some some real life object samples.

Mary is attending Elementary School. In her backpack she carries all her School supplies.

 

 

 We can call each one of the supplies including the Backpack an "Object". Some of these are:

    Backpack
    Sandwich
    Apple
    Banana
    Water Bottle
    Calculator
    Color Crayons
    Pencils
    Ruler
    Notebook

 

We can notice that each "Object" has "Properties".

Some of the properties of the Apple:

    Object Name: "Apple"
    Object Color: "Red"
    Object Type: "Food"
    Object has Seeds? "Yes"
    Object Need to be refrigerated? "No"

The Banana:

    Object Name: "Banana"
    Object Color: "Yellow"
    Object Type: "Food"
    Object has Seeds? "No"
    Object Need to be refrigerated? "No"

 

The Sandwich is an "Object" made of another "Objects" and also it has its own "Properties":

Object "Sandwich":

    Object "Ham":
        Name: "Honey Ham"
        Type: "Food"
        Need to be refrigerated? "Yes"
        Total Amount: 10
        Unit of Measure: Slice
    Object "Bread":
        Name: "Full Grain Bread"
        Type: "Food"
        Need to be refrigerated? "No"
        Total Amount: 25
        Unit of Measure: Slice
    Object "Cheese":
        Name: "Cheddar Cheese"
        Type: "Food"
        Need to be refrigerated? "Yes"
        Total Amount: 12
        Unit of Measure: Slice
    Object "Lettuce":
        Object Name: "Iceberg Lettuce"
        Object Color: "Green"
        Object Type: "Food"
        Object has Seeds? "No"
        Total Amount: 50
        Unit of Measure: Portion
    Ham Slices Count: "Not Defined Yet"
    Bread Slices Count: "Not Defined Yet"
    Cheese Slices Count: "Not Defined Yet"
    Has Mayo?: "Not Defined Yet"

 

 At this moment, we notice that the Sandwich has some "Properties" that say "Not Defined Yet". This is the initial "State" of the Sandwich "Object".

 There are "Actions" that can be taken for some of these "Objects" for changing their "State".

For Example, in the case of the Sandwich there is an "Action" that "Calls" another "Actions" in the included "Objects" and also an "Action" in the own Sandwich "Object":

Action "Make Me a Sandwich":

    From Included "Objects":
        "Action Add Some" of "Ham"
        "Action Add Some" of "Bread"
        "Action Add Some" of "Cheese"
        "Action Add Some" of "Lettuce"
    In "This" "Object":
        "Action Spread Some Mayo"

 

In Object Oriented Programming we call each "Object's" "Actions" a "Method" and each one may contain calls to other "Methods" or just simple logic to transform the "State" of the "Object" itself or another "Object's" "State" from "Stage 1" to "Stage 2".

When we refer to the "Object" itself we use the words "this" or "self".

We call all "Objects" used to make another one "Dependencies". In the case of the Sandwich "Object", its "Dependencies" are the "Ham", "Cheese", "Bread" and "Lettuce".

The action of including "Dependencies" is called "Dependency Injection" or "DI".

We use these "Objects" to encapsulate data and fragments of code in a well organized manner using these "Properties" and "Methods" to build Object Oriented Programs.

 

 

 

1 See Object definition by Merriam-Webster.