Home

ABCs of OOP Objects

Object / Container

OOP objects mimic (imitate) real world objects:

Like real world objects, OOP objects can play several "roles" at any given time:

  1. An object can be a container.
  2. A container can be an object.
  3. An object or container can “contain” other objects or other containers. For example, a dresser which is an object can contain “drawers” which are objects which in turn can contain other objects like clothing, socks, etc.

NOTES:

  1. In OOP, when objects (or containers) are nested inside of one another, you can drill down to them by using the dot syntax (e.g., myBody.myShirt.myButton could be used to drill down to the myButton object.
  2. However, it is always important to remember that you do not talk to the object, you talk to the property of that object which is the last item in a dot syntax. (e.g., myBody.myShirt.myButton.color where color is the color of the button, not myShirt or myBody. If you wanted to addressed the color of myShirt, you would write myBody.myShirt.color, or the color of myBody would simply be myBody.color.
  3. Typically, when an object is nested inside of another object, you create what is known as a "parent/child relationship" where children will inherit properties of its parent unless they defined their own.

In OOP, while just about everything is treated as an object, just about everything can also be treated as a container:

  1. Variable—is a container for a SINGLE data type
  2. Array—is a container for MULTIPLE data types
  3. Vector—is a container for MULTIPLE data types of the SAME type (Flash)
  4. Property—is a container to store variables of an object
  1. Loop—is a container to REPEAT lines of code
  2. Conditional Statement—is a container to TEST if a condition is true
  1. Function—is a container for a calculation or to perform a series of tasks
  2. Method—is  a container for an object to use its functions
  3. Event—is  a container for define trig-gers for an object
  1. Class—is a container to DEFINE properties and methods of an object
  2. Object—is a container to DESIGN an object based on a set of given properties and methods

In OOP, content of a container is contained within a set (pair) of:

  1. Square brackets: “[ … ]” (e.g., an array)
  2. Curly braces: “{ ... }” (e.g., an object)
  3. Parenthesis: “(...)” (e.g., function, etc.)
< Previous Topic     Next Topic >

© 2015. RMCS. All rights reserved.