Complex reference
From Wikipedia, the free encyclopedia
Complex reference in the concept-oriented programming (CoP) is used to represent objects in a hierarchical virtual address space. It consists of a sequence of segments where each next segment is a local identifier relative to the previous segment. Complex references are analogous to postal addresses. For example, a complex reference might be written as follows: <"Russia"; "Moscow"; "Red Square"; 1>. It consists of four segments starting from country name and ending with house number.
In CoP the format of each segment is described by the programmer in the reference class of a concept. The sequence of segments in a complex reference is defined by the inclusion relation (which is a generalized inheritance). Thus by means of concepts and inclusion it is possible to define custom virtual address spaces used to represent objects by means of complex references.
In the following example each account may have many sub-accounts which are described in the corresponding concepts:
concept Account reference { String accountNumber; ... } object { ... } concept SavingsAccount in Account reference { String subAccountNumber; ... } object { ... }
Thus a complex reference to a concrete savings account consists of two segments: one specifies the main account and the other specifies a sub-account within this account. For example, a variable referencing an account will contain actually two numbers for its account and sub-account:
Account account = getAccount(); SavingsAccount savingsAccount = getAccount();
Here the first variable may contain either one-segment reference to an Account
or a SavingsAccount
object. The second variable will contain a complex reference consisting of two or more segments.
Access to objects represented by complex references is transparent by creating a complete illusion of instantaneous action yet providing the programmer means for its customization. In particular, we can apply methods to complex references just if they were primitive (naitve) references:
account.getBalance(); savingsAccount.credit(25);
[edit] See also
- Concept-oriented programming
- Concept
- Inclusion
- Complex reference
- Continuation method
- Dual methods
- Concept-oriented model