All Topics  
Object (computer science)

 

   Email Print
   Bookmark   Link






 

Object (computer science)



 
 
In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variable
Variable

A variable is a symbol that stands for a value that may vary; the term usually occurs in opposition to constant, which is a symbol for a non-varying value, i.e....
s 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
Procedural programming

Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm based upon the concept of the procedure call....
, an object may contain data or instructions, but not both.






Discussion
Ask a question about 'Object (computer science)'
Start a new discussion about 'Object (computer science)'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variable
Variable

A variable is a symbol that stands for a value that may vary; the term usually occurs in opposition to constant, which is a symbol for a non-varying value, i.e....
s 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
Procedural programming

Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm based upon the concept of the procedure call....
, an object may contain data or instructions, but not both. (Instructions may take the form of a procedure or function.) In object-oriented programming
Object-oriented programming

Object-oriented programming is a programming paradigm that uses "Object_" and their interactions to design applications and computer programs....
, 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
JavaScript

JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard....
) an object can be created from nothing, or can be based on an existing object. In class-based languages (e.g., Java
Java (programming language)

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java ....
), objects are derived from classes
Class (computer science)

In object-oriented programming, a class is a programming language construct that is used as a blueprint to create Object s. This blueprint includes Attribute s and Method s that the created objects all share....
, which can be thought of as blueprint
Blueprint

A blueprint is a type of paper-based reproduction usually of a technical drawing, documenting an architecture or an engineering design. More generally, the term "blueprint" has come to be used to refer to any detailed plan....
s for constructing objects.

Theory

In strictly mathematical branches of computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 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
Primitive type

In computer science, primitive type can refer to either of the following concepts:* a basic type is a data type provided by a programming language as a basic building block....
 datatype in the discussion of more concrete branches (such as programming) that are closer to actual computation and information processing
Information processing

Information processing is the change of information in any manner detectable by an observation. As such, it is a Process which describes everything which happens in the universe, from the falling of a rock to the printing of a text file from a digital computer system....
. Therefore, objects are still conceptual entities, but generally correspond directly to a contiguous block of computer memory
Computer memory

Computer memory is usually meant to refer to the semiconductor technology that is used to store information in Electronics devices. Current primary computer memory makes use of integrated circuits consisting of silicon-based transistors....
 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 reference
Reference (computer science)

In computer science, a reference is an object containing information about how to locate and access the particular data item, as opposed to containing the data itself....
s, variable
Variable

A variable is a symbol that stands for a value that may vary; the term usually occurs in opposition to constant, which is a symbol for a non-varying value, i.e....
s, and name binding
Name binding

In programming languages, name binding is the association of Value s with identifiers. An identifier bound to a value is said to Reference that value....
. 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
Abstraction (computer science)

In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time....
 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
Data type

A data type in programming languages is an attribute of a data which tells the computer something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it....
 with it). Thus, the lifetime of an object
Object lifetime

In computer science, the object lifetime of an object in object-oriented programming is the time between an object's creation till the object is no longer used, and is destructed or freed....
 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
Design pattern (computer science)

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code ....
 exhibited by a set of classes, data type
Data type

A data type in programming languages is an attribute of a data which tells the computer something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it....
s in statically typed programs.

Objects in object-oriented programming

In object-oriented programming
Object-oriented programming

Object-oriented programming is a programming paradigm that uses "Object_" and their interactions to design applications and computer programs....
 (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. method
    Method (computer science)

    In object-oriented programming, a method is a subroutine that is exclusively associated either with a class or with an object . Like a procedure in procedural programming languages, a method usually consists of a sequence of statement to perform an action, a set of input parameter to customize those actions, and possibly an output value...
    s 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 invariant
Class invariant

In computer programming, a class invariant is an invariant used to constrain object s of a class . Method s of the class should preserve the invariant....
s 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
Class (computer science)

In object-oriented programming, a class is a programming language construct that is used as a blueprint to create Object s. This blueprint includes Attribute s and Method s that the created objects all share....
) called "dog", which is a subclass
Subclass (computer science)

In object-oriented programming, a subclass is a class that Inheritance some properties from its superclass .You can usually think of the subclass as being "a kind of" its superclass, as in a "a Manx is a kind of cat", or "a square is a kind of rectangle":...
 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
Reference (computer science)

In computer science, a reference is an object containing information about how to locate and access the particular data item, as opposed to containing the data itself....
 in a program
Computer program

Computer programs are Instruction for a computer. A computer requires programs to function. Moreover, a computer program does not run unless its instructions are executed by a Central processing unit; however, a program may communicate an Algorithm#Formalization of algorithms to people without running....
, and can therefore serve no purpose. In a garbage-collected language, the garbage collector
Garbage collection (computer science)

In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage , or memory used by Object that will never be accessed or mutated again by the Application software....
 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
    Identity (object-oriented programming)

    An identity in object-oriented programming, object-oriented design and object-oriented analysis describes the property of object s that distinguishes them from other objects....
    : 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
    Interface (computer science)

    Interface generally refers to an Abstraction_%28computer_science%29 that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide Polymorphism in object-orien...
     by which the object can be used


Some terms for specialized kinds of objects include:
  • Singleton
    Singleton pattern

    In software engineering, the singleton pattern is a design pattern that is used to restrict Instantiation of a class to one object-oriented programming....
     object: An object that is the only instance of its class during the lifetime of the program.
  • Functor (function object
    Function object

    A function object, also called a functor, functional or functionoid, is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function , usually with the same syntax....
    ): 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
    Immutable object

    In object-oriented computer programming and Functional_programming programming, an immutable object is an object whose state cannot be modified after it is created....
    : an object set up with a fixed state at creation time and which does not vary afterward.
  • First-class object
    First-class object

    In computing, a first-class object , in the context of a particular programming language, is an entity which can be used in programs without restriction ....
    : an object that can be used without restriction.
  • Container
    Container (data structure)

    In computer science, a container is a Class , a data structure, or an abstract data type whose instances are collections of other objects. They are used to store objects in an organized way following specific access rules....
    : an object that can contain other objects.
  • Factory object
    Factory object

    In object-oriented computer programming, a factory object is an object for creating other objects. It is an abstraction of a constructor , and can be used to implement various allocation schemes, such as the singleton pattern....
    : an object whose purpose is to create other objects.
  • Metaobject
    Metaobject

    In computer science, a metaobject or meta-object is any entity that manipulates, creates, describes, or implements other object s. The object that the metaobject is about is called the base object....
    : an object from which other objects can be created (Compare with class
    Class (computer science)

    In object-oriented programming, a class is a programming language construct that is used as a blueprint to create Object s. This blueprint includes Attribute s and Method s that the created objects all share....
    , which is not necessarily an object)
  • Prototype: a specialized metaobject from which other objects can be created by copying
  • God object
    God object

    In object-oriented programming, a God object is an object that knows too much or does too much. The God object is an example of an anti-pattern....
    : an object that knows
    too much or does too much. The God object is an example of an anti-pattern
    Anti-pattern

    In software engineering, an anti-pattern is a design pattern that appears obvious but is ineffective or far from optimal in practice.The term was coined in 1995 by Andrew Koenig ,...
    .
  • Antiobjects
    Antiobjects

    The notion of antiobjects is a computational metaphor useful to conceptualize and solve hard problems by swapping computational foreground and background....
    : a computational metaphor useful to conceptualize and solve hard problems often with massively parallel approaches by swapping computational foreground and background.....
  • Filter object
    Filter object

    In object-oriented programming, a filter object is an object which receives a stream of data as its input and produces the stream of data as its output based on the data from input stream....


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
Encapsulation (computer science)

In computer science, Encapsulation is the hiding of the internal mechanisms and data structures of a software component behind a defined interface, in such a way that users of the component only need to know what the component does, and cannot make themselves dependent on the details of how it does it....
, can be carried over to the realm of distributed computing
Distributed computing

Distributed computing deals with hardware and software systems containing more than one processing element or Computer data storage element, Concurrent computing processes, or multiple programs, running under a loosely or tightly controlled regime....
. A number of extensions to the basic concept of an object have been proposed that share these common characteristics:
  • Distributed objects
    Distributed object

    The term distributed objects usually refers to Computer software modules that are designed to work together, but reside either in multiple computers connected via a Computer network or in different Process inside the same computer....
    are "ordinary" objects (objects in the usual sense) that have been deployed at a number of distinct remote locations, and communicate by exchanging messages over the network. Examples include web services
    Web service

    A Web service is defined by the W3C as "a software system designed to support interoperability Machine to Machine interaction over a computer network"....
     and DCOM
    Component Object Model

    Component Object Model is an interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages....
     objects.
  • Protocol objects are components of a protocol stack
    Protocol stack

    A protocol stack is a particular software implementation of a computer networking protocol suite. The terms are often used interchangeably....
     that encapsulate network communication within an object-oriented interface.
  • Replicated objects
    Replication (computer science)

    Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, fault-tolerance, or accessibility....
    are groups of distributed objects (called replicas) that run a distributed multi-party protocol to achieve a high degree of consistency between their internal states, and that respond to requests in a coordinated manner. Referring to the group of replicas jointly as an object reflects the fact that interacting with any of them exposes the same externally visible state and behavior. Examples include fault-tolerant CORBA
    Çorba

    Chorba , shurpa , sorpa , or shorpo is one of various kinds of soup or stew found in national cuisines across Eurasia. The term is likely of Persian language or Turkic languages origin....
     objects.
  • Live distributed objects
    Live distributed object

    Definitions The term live distributed object refers to a running instance of a distributed computing multi-party protocol , viewed from the object-oriented programming perspective, as an entity that has a distinct identity , may Encapsulation internal State and Thread , and that exhibits a well-defined externally visible behavior....
    (or simply live objects
    Live distributed object

    Definitions The term live distributed object refers to a running instance of a distributed computing multi-party protocol , viewed from the object-oriented programming perspective, as an entity that has a distinct identity , may Encapsulation internal State and Thread , and that exhibits a well-defined externally visible behavior....
    ) generalize the replicated object concept to groups of replicas that might internally use any distributed protocol, perhaps resulting in only a weak consistency between their local states.


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
Remote procedure call

Remote procedure call is an Inter-process communication technology that allows a computer program to cause a subroutine or procedure to execute in another address space without the programmer explicitly coding the details for this remote interaction....
 or protocol composition
Protocol stack

A protocol stack is a particular software implementation of a computer networking protocol suite. The terms are often used interchangeably....
). 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
Semantic Web

The Semantic Web is an evolving extension of the World Wide Web in which the semantics of information and services on the web is defined, making it possible for the web to understand and satisfy the requests of people and machines to use the web content....
 can be seen as a distributed data objects framework, and therefore can be validly seen as an Object Oriented Framework . 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:
  • Classes
  • Attributes (also known as Relationships)
  • Instances


Furthering this, Linked Data
Linked Data

Linked Data is a term used to describe a method of exposing, sharing, and connecting data on the Semantic Web via dereferenceable URIs....
 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

  • Object lifetime
    Object lifetime

    In computer science, the object lifetime of an object in object-oriented programming is the time between an object's creation till the object is no longer used, and is destructed or freed....
  • Object copy
    Object copy

    One of the most common procedures that occurs in computer programs is the copying of data. An object is a composite data type in object-oriented programming languages....
  • Design patterns
    Design pattern (computer science)

    In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code ....
  • Business object
    Business object (computer science)

    Business objects are object oriented in an object oriented computer program that represent the entities in the business domain that the program is designed to support....
  • Actor model
    Actor model

    In computer science, the Actor model is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent digital computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message receiv...


External links

  • from The Java Tutorials