Object (computer science) explained

In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variables to access objects, the terms object and variable are often used interchangeably. However, until memory is allocated, an object does not exist.

All programming languages present objects. The presence of objects should not be confounded with the concept of object-orientation.

In procedural programming, an object may contain data or instructions, but not both. (Instructions may take the form of a procedure or function.) In object-oriented programming, an object may be associated with both the data and the instructions that operate on that data. How an object is created varies among language. In prototype-based languages (e.g., JavaScript) an object can be created from nothing, or can be based on an existing object. In class-based languages (e.g., Java), objects are derived from classes, which can be thought of as blueprints for constructing objects.


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  - object oriented programming.

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, an object's private implementation details must not be exposed to clients of the object, and they must be able to change without requiring changes to client code. In particular, the size of the block of memory that forms the object 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.

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, the data members can only be accessed through the methods, 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 almost all object-oriented programming languages, a dot(.) operator is used to call a particular method/function of an object. For example, consider an arithmetic class named Arith_Class. This class contains functions like add, subtract, multiply and divide, that process results for two numbers sent to them. This class could be used to find the product of 78 and 69 by first of all creating an object of the class and then invoking its multiply method, as follows:

1 int result = 0; // Initialization 2 arith_Obj1 = new Arith_Class; // Creating a new instance of Arith_Class 3 result = arith_Obj1.multiply(78,69); // Product of 78 and 69 stored in result variable

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 that is unreferenced in a program, and can therefore serve no purpose. In a garbage-collected language, the garbage collector would mark the memory occupied by the object as free, although it would still contain the object's data until it was overwritten.

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. Behavior: describes the methods in the object's interface by which the object can be used

Some terms for specialized kinds of objects include:

an object set up with a fixed state at creation time and which does not vary afterward.

an object that can be used without restriction.

an object that can contain other objects.

an object whose purpose is to create other objects.

an object from which other objects can be created (Compare with class, which is not necessarily an object)

a specialized metaobject from which other objects can be created by copying

an object that knows too much or does too much. The God object is an example of an anti-pattern.

a computational metaphor useful to conceptualize and solve hard problems often with massively parallel approaches by swapping computational foreground and background.....

Objects in distributed computing

The definition of an object as an entity that has a distinct identity, state, and behavior, and the principle of encapsulation, can be carried over to the realm of distributed computing. A number of extensions to the basic concept of an object have been proposed that share these common characteristics:

Some of these extensions, such as distributed objects and protocol objects, are domain-specific terms for special types of "ordinary" objects used in a certain context (such as remote invocation or protocol composition). Others, such as replicated objects and live distributed objects, are more non-standard, in that they abandon the assumption that an object resides in a single location at a time, and apply the concept to groups of entities (replicas) that might span across multiple locations, might have only weakly consistent state, and whose membership might dynamically change.

Objects and the Semantic Web

The Semantic Web can be seen as a distributed data objects framework, and therefore can be validly seen as an Object Oriented Framework [2] [3] . It is also quite valid to use a UML diagram to express a Semantic Web graph.

Both the Semantic Web and Object Oriented Programming have:

Furthering this, Linked Data also introduces Dereferenceable Unified Resource Identifiers, which provide Data-by-Reference which you find in Object Oriented Programming and Object Oriented Databases in the form of Object Identifiers.

See also

External links

Notes and References

  1. Ostrowski, K., Birman, K., Dolev, D., and Ahnn, J. (2008). "Programming with Live Distributed Objects", Proceedings of the 22nd European Conference on Object-Oriented Programming, Paphos, Cyprus, July 07 - 11, 2008, J. Vitek, Ed., Lecture Notes In Computer Science, vol. 5142, Springer-Verlag, Berlin, Heidelberg, 463-489, http://portal.acm.org/citation.cfm?id=1428508.1428536.
  2. Web site: A Semantic Web Primer for Object-Oriented Software Developers. Knublauch. Holger. Oberle. Daniel. Tetlow. Phil. Wallace,Evan. W3C. 2006-03-09. 2008-07-30.
  3. Web site: An Evaluation of the World Wide Web with respect to Engelbart's Requirements. Connolly. Daniel. W3C. 2002-08-13. 2008-07-30.