Object (computer science)

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 in the discussion of more concrete branches (such as programming) that are closer to actual computation and information processing. There, 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 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.

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.

Objects in Object-Oriented Programming

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:

  1. data members that represent the data associated with the object.
  2. methods that access the data members in predefined ways.

In the case of most objects, one can access the data members only through the method members, making it easy to guarantee that the data will always remain in a well-defined state (class invariants will be enforced). Some languages do not make distinctions between data members and methods.

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.

Three properties characterize objects:

  1. identity - the property of an object that distinguishes it from other objects
  2. state - describes the data stored in the object
  3. behaviour - describes the methods in the object's interface by which the object can be used

Some terms for specialized kinds of objects include:

  • Singleton object - An object that will only allow itself to be instantiated once during the lifetime of the program.
  • Functor (function object) - an object with a single method (in C++, this method would be the function operator, "operator()") that acts much like a function (like a C/C++ pointer to a function).
  • Immutable object - an object set up with a fixed state at creation time and which does not vary afterward.
  • First-class object - an object that can be used without restriction.
  • Container object - an object that can contain other objects.
  • Factory object - a metaobject that can create other objects.
  • Metaobject - an object from which other objects can be created (Compare with class, which is not necessarily an object)
  • Prototype - a specialized metaobject from which other objects can be created by copying

See also


de:Objekt_(objektorientierte_Programmierung) lt:Objektas (programavimas) nl:Object (informatica) ja:インスタンス pl:Obiekt (programowanie obiektowe) zh:对象

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools