We are using cookies to give you the best experience on our site. Cookies are files stored in your browser and are used by most websites to help personalise your web experience.
By continuing to use our website without changing the settings, you are agreeing to our use of cookies.

Concept (concept-oriented programming)

From The Concept-Oriented Portal
Jump to: navigation, search

Concept is the main programming construct in the concept-oriented programming (COP). Concept is defined as a pair of two classes:

  • Reference class and
  • Object class

Instances of the reference class are called references (or identities). They are passed-by-value and do not have their own representatives by playing a role of representatives for objects. Instances of the object class are called objects (or entities). They are indirectly passed-by-reference.

Concepts generalize conventional classes as used in OOP. Concept with the empty reference class is equivalent to a class and class with an additional reference class attached to it is a concept. Concepts in the concept-oriented program are used just as traditional classes when declaring variables, fields, parameters, return values and other elements where we need a type.

Any concept has a parent or base concept which is specified using concept inclusion relation. The inclusion structure of concepts defines how objects in the program are represented and accessed by defining their format of references.

Here is an example of concept definition:

   concept SavingsAccount in Account 
       reference {
           String subAccountNumber; // Identifier 
           balance getBalance() { ... } 
           void continue() { ... } // Continuation method 
           void create() { ... } // Reference constructor 
           void delete() { ... } // Reference destructor 
       object {
           double balance; 
           double getBalance() { ... } 
           void create() { ... } // Object constructor 
           void delete() { ... } // Object destructor 

Concept may have two versions of each method, called dual methods: one is defined in its reference class and the other is defined in its object class (like getBalance in the above example).

An important application of dual methods is life-cycle management. Concepts may define a pair of dual creation methods (called create) and a pair of deletion methods, called delete. The creation/deletion methods of the object class are intended to initialize/clean up the object and they are equivalent to constructor/destructor. The creation/deletion methods of the reference class are intended to initialize/clean up the reference and they are specific to COP.

Concept also defines one continuation method, called continue, which is called whenever the object represented by this reference needs to be accessed. The continuation method of the reference class is used to resolve this reference into the native (system) reference that can be used to 'directly' access the represented object. Thus the continuation methods provide a door or portal which is used to intersect the border described by the concept.

See also

External links

Personal tools
Google AdSense