Online Encyclopedia Search Tool

Your Online Encyclopedia


Online Encylopedia and Dictionary Research Site

Online Encyclopedia Free Search Online Encyclopedia Search    Online Encyclopedia Browse    welcome to our free dictionary for your research of every kind

Online Encyclopedia

Object (computer science)

(Redirected from Instance)

An object is fundamental concept in object-oriented programming. Generally, something is an object if it has a name, properties associated with it, and messages that it can understand. Objects are the basic units of modeling in object-oriented design and the basic units of programs in object-oriented programming. Object-oriented programming involves modeling the software system as a set of interacting (conceptual) objects in object-oriented design, then implementing (coding) the design using an object-oriented programming language with (programming language) objects.


Characteristics and Terminology

Objects have three defining characteristics: identity, state and behavior. An object has an identity if that object can be distinguished from other objects (usually with a name). The state of an object describes the properties (or data stored) in the object. The behavior of an object describes the messages the object can understand (methods in the object's interface).

The state of an object can be referred to using a number of terms: properties, attributes, members, or data members. The messages that an object understand can be referred to as methods or member functions. The terminology of choice depends on the context of use. For example, in C++ objects have data members and member functions, while in Java objects have attributes and methods.

Objects are instances of a class.


In simple conceptual terms, a class is a stencil or mold for an object. Assume we have a class called Dog that is capable of having certain properties and can understand certain messages. Then, we can create an instance of that class, an object named "Fido". The object Fido can have specific properties and can perform certain actions based on the messages it understands. For instance, Fido can be male, brown, and can stay, sit, and roll over.

In an object-oriented programming language, we may see a class Dog and instantiated objects Fido and Princess defined as:

 define class Dog with {
      attribute gender in {male, female};
      attribute color in {white, brown, black, tan};
           ... other attributes ...
      method fetch() returns Ball;
      method stay() returns nothing;
      method rollover() returns nothing;
      method eat(Food) returns nothing;
           ... other methods ...
 create Fido;
 Fido.gender = male;
 Fido.color = brown;
 create Princess;
 Princess.gender = female;
 Princess.color = white;
 if not Fido.isSitting() then

The above example is not specific to any programming language, but describes the concepts one would normally see in an object-oriented programming language.

Note that objects can represent real-life objects, but do not necessarily have to. Objects can model concepts that do not have a real physical representation.

Some Specialized Objects

  • Singleton object - an object that is one-of-a-kind, in other words, no other objects of its class are created during the lifetime of the program.
  • Functor function object - an object with a single method that acts much like a function.
  • Immutable object - an object whose state is fixed in the creation and does not vary afterward.
  • First-class object
  • Container object
  • Factory object

See also

Last updated: 02-16-2005 08:47:25
Last updated: 02-25-2005 20:49:10