Object (programming)

from Wikipedia, the free encyclopedia

In object- oriented programming, an object (also called an instance ) denotes an instance of a certain data type or a certain class (also called “object type”). Objects are specific manifestations (“instances”) of an object type and are created during runtime ( instantiation ). They are assignment compatible not only with their own classes , but also with the corresponding base classes .

In addition, the term “object” can only stand for a certain area in ( virtual ) main memory , which is the case in particular with non-object-oriented programming languages such as C.


Every object has a state, a behavior and an identity. The state of the object is made up of its properties ( attributes ) and connections to other objects. The behavior of the object is described by the number of its methods . Identity distinguishes an object from other objects, even if these other objects have the same state and behavior.

Through construction (see also constructors and destructors ) an object or instance ( instance ) is created from a class . This instance then has its own data type , properties and methods at runtime .


In object-oriented programming, instantiation is the creation of a concrete object of a certain class . During the instantiation of an object, a so-called constructor is executed in many programming languages .

The instance of a class is a specific instance with specific characteristics that can be worked with until it is destroyed. For example, in a program that works with cars (for example shop software) there could be a class “car” in which the properties of a car are described as abstractly as possible. If a specific car, for example “Porsche, black, vehicle number X” is created in such a program, which is then available to the program for further use, this is now called an instance of the “car” class and the process object creation is called instantiation .

Origin of the term instance

There is the assumption that today's linguistic usage “An object is an instance of a class” is based on a mistranslation of the English term “instance” = “example”, “occurrence” or “case”. The reason is the observation that instances in the legal context are always in a superordinate or subordinate relationship to one another. However, this assumption is called wrong by critics : The Latin root “instantia” = “to insist” does not contain such a hierarchy of instances. Rather, instances must insist on other things, which instances of classes do (they insist on classes, or more precisely, they are created from a class in programming at runtime ). Even Goethe used the term "entity" as early as the meaning of " copy ": "An instance of the animal kingdom the lowest level we still lead to several instructions before here."


The object type (class) "Book" with the identifying property "Inventory number" (in the case of a library and as a single instance) contains the associated properties (inventory number, loan status, acquisition date, ...) and the description for editing the properties (the methods, such as changing the loan status in the event of a loan by a customer).

An object is then a real occurrence of the class , i.e. a specific book, such as B. with the inventory number 4711. Object-oriented programming languages allow the simultaneous coexistence of different objects, i.e. a book with the number 4711 and 1234.

Difference between entity and object

The term object is related to the term entity in programming .

The terms entity and entity type are used in data modeling , e.g. B. used in the ER model . Entity types have attributes but not methods .

The terms object and class , however, are used in object-oriented programming . An object type (class) is the programmatic representation of an entity type, extended by the associated processing functions ( methods ).

Semantic Web

The Semantic Web is essentially a framework for distributed objects. Two key technologies in the Semantic Web are the Web Ontology Language (OWL) and the Resource Description Framework (RDF). RDF provides the ability to define basic objects - names, properties, attributes, relationships - that can be accessed over the Internet . OWL adds a more extensive object model that is based on set theory and offers additional modeling functions such as multiple inheritance .

OWL objects are not like standard distributed objects that are accessed through an interface description language. Such an approach would not be suitable for the Internet because the Internet is constantly evolving and standardization on a number of interfaces is difficult to achieve. OWL objects are typically similar to the type of objects used to define application domains in object-oriented programming languages.

However, there are important differences between OWL objects and traditional object-oriented programming objects . Traditional objects are usually compiled into static hierarchies using simple inheritance , but OWL objects are dynamic. An OWL object can change its structure at runtime and become an instance of new or different classes .

Another critical difference is the way the model handles information that is not currently in the system. Programming objects and most database systems use the closed world assumption . When a fact is not known to the system, it is believed that that fact is false. Semantic Web objects use the open world assumption . A statement is only considered false if there is actually relevant information that it is false. Otherwise, it is assumed to be unknown, neither true nor false.

OWL objects actually resemble objects in frame languages ​​with artificial intelligence like KL-ONE and Loom.

The following table compares traditional objects from object-oriented programming languages such as C # , C ++ and Java with Semantic Web Objects:

Object-oriented programming languages OWL and RDF
Classes and Instances
Classes are considered types for instances. Classes are viewed as groups of individuals.
Each instance has a class as a type. Classes cannot share instances. Each individual can belong to several classes.
Instances cannot change their type at runtime. Class membership can change at runtime.
The list of classes is fully known at the time of compilation and cannot be changed afterwards. Classes can be created and modified at runtime.
Compilers are used at build time. Compilation errors indicate problems. Reasoners can be used for classification and consistency checking at runtime or at creation time.
Properties, attributes and values
Properties are defined locally for a class and its subclasses through inheritance. Properties are independent entities that can exist without specific classes.
Instances can only have values ​​for the attached properties. The values ​​must be entered correctly. Range restrictions are used for type testing. Instances can have any value for any property. Area and domain restrictions can be used for type checking and type inference.
Classes implement much of their meaning and behavior through imperative functions and methods. Classes make their meaning explicit in the form of OWL statements. No mandatory code can be attached.
Classes can encapsulate their members for private access. All parts of an OWL file or RDF file are public and can be linked from any other location.
Closed world assumption : If there is not enough information to prove a statement to be true, it is assumed to be false. Open world assumption : If there is not enough information to prove a statement to be true, it can be true or false.
Role in the design process
Some generic APIs are shared between applications. Only a few UML diagrams are shared. RDF and OWL were designed from the ground up for the web. Domain models can be shared online.
Domain models are designed as part of a software architecture. Domain models are used to represent knowledge about a domain and for information integration.
UML, Java, C #, etc. are mature technologies that are supported by many commercial and open source tools. The Semantic Web is an emerging technology with some open source tools and a handful of commercial providers.
Different functions
Instances are anonymous in that they cannot simply be addressed from outside of an executing program. All of the RDF and OWL resources mentioned have a unique URI under which they can be referenced.
UML models can be serialized to XML, which is designed for tool sharing, but not actually web-based. Java objects can be serialized in various XML-based or native intermediate formats. RDF and OWL objects have a standard XML-based serialization with unique URIs for each resource in the file.

Objects in C


The C programming language has a pragmatic definition of what counts as an object:

region of data storage in the execution environment, the contents of which can represent values
Note: When referenced, an object may be interpreted as having a particular type; see

- ISO / IEC 9899: 1999 : §3.14

However, C is not considered an object-oriented programming language. The concepts of object-oriented software development , such as inheritance , polymorphism and data encapsulation, are missing in the language core and must be recreated using self-defined functions . Various third-party libraries exist for this purpose. If an object is accessed exclusively via these functions, it fulfills the criteria of an object from an object-oriented point of view.


The state of an object in the sense of the definition mentioned is completely determined by the values ​​of its attributes . Unnamed attributes as well as filling bits and bytes (padding) do not contribute anything to the defined state of the object; their content is undefined.

C has no methods. These must be simulated using functions that receive a pointer to the object as the first parameter . Polymorphism is implemented using function pointers that are stored as attributes in the object.

The unique identity of an object is defined by its memory address . Each object must therefore have its own memory address. This is ensured by each data structure occupying at least 1 byte of memory. However, if the memory address of an object is not required in the program and the compiler can recognize this, it is possible that no memory is reserved for this object, as this does not change the semantics of the program.

Individual evidence

  1. ^ Heide Balzert: Textbook of object modeling: Analysis and design . Spektrum Akademischer Verlag, Heidelberg 1999, ISBN 3-8274-0285-9 , p. 18 .
  2. ^ Johann Wolfgang von Goethe: Formation and reshaping of organic natures. About morphology . Volume 1, Issue 1; Year 1817
  3. Holger Knublauch, Daniel Oberle, Phil Tetlow, Evan Wallace: A Semantic Web Primer for Object-Oriented Software Developers . W3C . March 9, 2006. Retrieved July 30, 2008.