An object consists of both data and methods for manipulating that data. An object is an instance of a class, which means that there is memory allocated for that specific instance of the class. An essential characteristic of objects is that they encapsulate data. Other objects or external code cannot access the object’s data directly, but they request data from the object by sending messages to it. Read that sentence again, as it speaks from the very heart of object-oriented development. Other objects or external code cannot access the object’s data directly, but they request data from the object by sending messages to it. Your job is to make those objects talk to one another and share information through their methods.
An object invokes methods corresponding to messages that are passed to it and may return data to whoever sent the message. An object’s methods do the encapsulating, in effect, regulating access to the object’s data. An object’s methods are also its interface, articulating the ways in which the object communicates with the outside world.
Because an object encapsulates a defined set of data and logic, you can easily assign it to particular duties within a program. Conceptually, it is like a functional unit—for instance, “customer Record”—that you can move around on a design board; you can then plot communication paths to and from other objects based on their interfaces.
When designing an object-oriented application, it is often helpful to depict the relationships between objects graphically. This document depicts objects graphically as shown in Figure 1-1.
See The Objective-C 2.0 Programming Language for a fuller description of data encapsulation, messages, methods, and other things pertaining to object-oriented programming.
Last updated: 2007-10-31