In the programming paradigm, object-oriented programming, an object is an individual unit of run-time data storage that is used as the basic building block of programs. These objects act on each other, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. Each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine or actor with a distinct role or responsibility.
In strictly mathematical branches of computer science the term object is used in a purely mathematical sense to refer to any "thing". While this interpretation is useful in the discussion of abstract theory, it is not concrete enough to serve as a primitive datatype in the discussion of more concrete branches (such as programming) that are closer to actual computation and information processing. Therefore, objects are still conceptual entities, but generally correspond directly to a contiguous block of computer memory of a specific size at a specific location. This is because computation and information processing ultimately require a form of computer memory. Objects in this sense are fundamental primitives needed to accurately define concepts such as references, variables, and name binding. This is why the rest of this article will focus on the concrete interpretation of object rather than the abstract one.
Note that although a block of computer memory can appear contiguous on one level of abstraction and incontiguous on another, the important thing is that it appears contiguous to the program that treats it as an object. That is, as far as the program is concerned the object must be free of internal references, because otherwise it is no longer a primitive. In other words, object's private storage details must not be exposed to clients of the object, and must be able to change without changes to client code.
Objects exist only within contexts that are aware of them; a piece of computer memory only holds an object if a program treats it as such (for example by reserving it for exclusive use by specific procedures and/or associating a data type with it). Thus, the lifetime of an object is the time during which it is treated as an object. This is why they are still conceptual entities, despite their physical presence in computer memory.
In other words, abstract concepts that do not occupy memory space at runtime are, according to the definition, not objects; e.g., design patterns exhibited by a set of classes, data types in statically typed programs.
To emphasize that an object actually contains meaningful data, a term data object is sometimes used to refer to such an object.
In object-oriented programming (OOP), an instance of a program (i.e. a program running in a computer) is treated as a dynamic set of interacting objects. Objects in OOP extend the more general notion of objects described above to include a very specific kind of typing, which among other things allows for:
In a language where each object is created from a class, an object is called an instance of that class. If each object has a type, two objects with the same class would have the same datatype. Creating an instance of a class is sometimes referred to as instantiating the class.
A real-world example of an object would be "my dog", which is an instance of a type (a class) called "dog", which is a subclass of a class "animal". In the case of a polymorphic object, some details of its type can be selectively ignored, for example a "dog" object could be used by a function looking for an "animal". So could a "cat", because it too belongs to the class of "animal". While being accessed as an "animal", some member attributes of a "dog" or "cat" would remain unavailable, such as the "tail" attribute, because not all animals have tails.
A ghost is an object with no reference and therefore serves no purpose in the program. The garbage collector then marks the memory as free, although it still contains the object data until it's overwritten.
Three properties characterize objects:
Some terms for specialized kinds of objects include:
Objekt (datalogi) | Objekt (Programmierung) | Objekto (komputiko) | Oggetto (informatica) | Objektas (programavimas) | Object (informatica) | インスタンス | Obiekt (programowanie obiektowe) | Objeto | Экземпляр (программирование) | 对象 (计算机科学)
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Object (computer science)".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world