You are here

Objects

9 March, 2015 - 14:11
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/402b20ad-c01f-45f1-9743-05eadb1f710e@37.6

In the "real" world, objects are the entities of which the world is comprised. Everything that happens in the world is related to the interactions between the objects in the world. Just as atoms, which are objects, combine to form molecules and larger objects, the interacting entities in the world can be thought of as interactions between and among both singular ("atomic") as well as compound ("composed") objects. The real world consists of many, many objects interacting in many ways. While each object may not be overly complex, their myriad of interactions creates the overall complexity of the natural world. It is this complexity that we wish to capture in our software systems.

In an object-oriented software system, objects are entities used to represent or model a particular piece of the system.

Objects are the primary units used to create abstract models.

There are a number of schools of object-oriented programming, which differ slightly on how they view objects. Here, we will take a "behaviorist" (our term) stance:

An object is characterized solely by it behaviors.

Essentially this defines an object by the way it interacts with its world. An object that does not interact with anything else effectively does not exist. Access to internally stored data is necessarily through some sort of defined behavior of the object. It is impossible for an outside entity to truly "know" whether or not a particular piece of data is being stored inside of another object.

Note: A beautiful example of a model that exhibits a particular behavior but without exactly replicating the mechanics we expect to produce that behavior is the "Dragon" optical illusion. A printout to create this simple folded paper display can be found at the web site of the Grand Illusions Toy Shop in England

This does not mean however, that an object may not contain data (information) in fields. The essence of the object is in how the object behaves in relationship to or as a result of its data, should it contain any.

The existence of data in an object is an implementation technique used to generate the required behavior of that object.