Object (computer science)
In computer science, an object can be a variable, a data structure, a function, or a method, and as such, is a value in memory referenced by an identifier.
In the class-based and object-oriented programming paradigms, object refers to a particular instance of a class, where the object can be a combination of variables, functions, and data structures.
In the relational model of database management, an object can be a table or column, or an association between data and a database entity.
Object-based languagesAn important distinction in programming languages is the difference between an object-oriented language and an object-based language. A language is usually considered object-based if it includes the basic capabilities for an object: identity, properties, and attributes. A language is considered object-oriented if it is object-based and also has the capability of polymorphism and inheritance. Polymorphism refers to the ability to overload the name of a function with multiple behaviors based on which object are passed to it. Conventional message passing discriminates only on the first object and considers that to be "sending a message" to that object. However, some OOP languages such as Flavors and the Common Lisp Object System enable discriminating on more than the first parameter of the function. Inheritance is the ability to subclass an object class, to create a new class that is a subclass of an existing one and inherits all the data constraints and behaviors of its parents but also adds new and/or changes one or more of them.software systems. The object-oriented approach is an evolution of good design practices that go back to the very beginning of computer programming. Object-orientation is simply the logical extension of older techniques such as structured programming and abstract data types. An object is an abstract data type with the addition of polymorphism and inheritance.
Rather than structure programs as code and data, an object-oriented system integrates the two using the concept of an "object". An object has state and behavior. Objects can correspond to things found in the real world. So for example, a graphics program will have objects such as circle, square, menu. An online shopping system will have objects such as shopping cart, customer, product. The shopping system will support behaviors such as place order, make payment, and offer discount. The objects are designed as class hierarchies. So for example with the shopping system there might be high level classes such as electronics product, kitchen product, and book. There may be further refinements for example under electronic products: CD Player, DVD player, etc. These classes and subclasses correspond to sets and subsets in mathematical logic.
Specialized objectsAn important concept for objects is the design pattern. A design pattern provides a reusable template to address a common problem. The following object descriptions are examples of some of the most common design patterns for objects.
- Function object: an object with a single method that acts much like a function.
- Immutable object: an object set up with a fixed state at creation time and which does not change afterward.
- First-class object: an object that can be used without restriction.
- Container object: an object that can contain other objects.
- Factory object: an object whose purpose is to create other objects.
- Metaobject: an object from which other objects can be created.
- Prototype object: a specialized metaobject from which other objects can be created by copying
- God object: an object that knows or does too much.
- Singleton object: an object that is the only instance of its class during the lifetime of the program.
- Filter object: an object that receives a stream of data as its input and transforms it into the object's output. Often the input and output streams are streams of characters, but these also may be streams of arbitrary objects. These are generally used in wrappers since they conceal the existing implementation with the abstraction required at the developer side.
A standard method to package distributed objects is via an Interface Definition Language. An IDL shields the client of all of the details of the distributed server object. Details such as which computer the object resides on, what programming language it uses, what operating system, and other platform specific issues. The IDL is also usually part of a distributed environment that provides services such as transactions and persistence to all objects in a uniform manner. Two of the most popular standards for distributed objects are the Object Management Group's CORBA standard and Microsoft's DCOM.
In addition to distributed objects, a number of other extensions to the basic concept of an object have been proposed to enable distributed computing:
- Protocol objects are components of a protocol stack that enclose network communication within an object-oriented interface.
- Replicated objects are groups of distributed objects that run a distributed multi-party protocol to achieve high consistency between their internal states, and that respond to requests in a coordinated way. Examples include fault-tolerant CORBA objects.
- Live distributed objects 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.
OWL objects are not like standard large grained distributed objects accessed via an Interface Definition Language. Such an approach would not be appropriate for the Internet because the Internet is constantly evolving and standardization on one set of interfaces is difficult to achieve. OWL objects tend to be similar to the kind of objects used to define application domain models in programming languages such as Java and C++.
However, there are important distinctions between OWL objects and traditional object-oriented programming objects. Traditional objects get compiled into static hierarchies usually with single inheritance, but OWL objects are dynamic. An OWL object can change its structure at run time and can become an instance of new or different classes.
Another critical difference is the way the model treats information that is currently not in the system. Programming objects and most database systems use the "closed-world assumption". If a fact is not known to the system that fact is assumed to be false. Semantic Web objects use the open-world assumption, a statement is only considered false if there is actual relevant information that it is false, otherwise it is assumed to be unknown, neither true nor false.
OWL objects are actually most like objects in artificial intelligence frame languages such as KL-ONE and Loom.
The following table contrasts traditional objects from Object-Oriented programming languages such as Java or C++ with Semantic Web Objects:
|OOP Objects||Semantic Web Objects|
|Classes are regarded as types for instances.||Classes are regarded as sets of individuals.|
|Instances can not change their type at runtime.||Class membership may change at runtime.|
|The list of classes is fully known at compile-time and cannot change after that.||Classes can be created and changed at runtime.|
|Compilers are used at build-time. Compile-time errors indicate problems.||Reasoners can be used for classification and consistency checking at runtime or build-time.|
|Classes encode much of their meaning and behavior through imperative functions and methods.||Classes make their meaning explicit in terms of OWL statements. No imperative code can be attached.|
|Instances are anonymous insofar that they cannot easily be addressed from outside of an executing program.||All named RDF and OWL resources have a unique URI under which they can be referenced.|
|Closed world: If there is not enough information to prove a statement true, then it is assumed to be false.||Open world: If there is not enough information to prove a statement true, then it may be true or false.|