Difference between revisions of "XCSG:Classifier"

From AtlasWiki
Jump to: navigation, search
(Specifications: Removing useless GeneralizableElement abstraction)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
Classifier is the parent of Interface, Class, and Datatype in the metamodel.  It defines structure and behavior in terms of features (attributes, operations, and methods). The features, associations, and constraints defined by a Classifier are inherited by all its subtypes (children).
+
A Classifier is a [[Type]] which may have [[Field]]s and/or [[Method]]s, such as a class, interface, or struct. They serve as templates for runtime instances, and may [[Extends|extend]] other classifiers.  
  
The semantics of Classifier are those defined by UML [5, pp. 2-30, 2-61].  However, only the attributes and associations given above are of interest.
+
Because languages differ in the semantics of specific subtypes of classifiers, XCSG provides the language-specific subtypes, but does not attempt to provide generic subtypes of Classifier; instead, the role of a classifier can be distinguished by its features: if it has only abstract methods, its role is likely that of an interface, if it has only concrete methods, then it is likely a class, if it is actually constructed and used, that can usually be seen from inspecting data flow (exceptions may include construction by injection frameworks or construction by means of reflection).
  
Inv supports the specification of user defined invariants in an OCL-like style. It is equivalent to associating a constraint with the element that has the stereotype «invariant», but less cumbersome to write.  Such invariants must be established by constructors (object initialization methods) and maintained by other operations associated with the Classifier.  The invariant is implicitly a part of the precondition and the postcondition of every public operation.
+
== Specification ==
 
+
The use of the subtyping (Generalization) relationship between classifiers implies behavioral subtyping as well as inheritance: an instance of a child is substitutable for an instance of a parent in any context in which the parent appears.  The required relationships between parent and child elements are those defined by Liskov [18], and described (less formally) by Meyer [19][20].
+
 
+
The subtyping relationship can be extended to include multiple dispatch as described by Castagna [21] and Leavens [39] by stereotyping the Classifier (with «multipleDispatch»).
+
 
+
The UML 1.4 semantics of for inheritance involve taking the union of the all the features inherited by a given classifier together with those defined by the classifier itself.  The model is considered ill-formed if this result contains more than one feature with the same signature. 
+
 
+
This rule is applied recursively to deal with hierarchies with a depth greater than two, i.e. the feature set formed for each classifier is inherited by each of its children, the feature set formed for each of these children is inherited by their children, etc.
+
 
+
Because features are combined using union, each inherited feature will appear only once in the result, even if it is inherited by more than one path (appears in the feature set of more than one parent).  [In the terminology of Bertrand Meyer [Object Oriented Software Construction], features are shared rather than replicated]. Because a Classifier is a Namespace, the resulting set of features may not contain different features with the same signature.
+
 
+
The introduction of feature redefinition in UML 2 extends these semantics.  If redefinition is not used, the results are the same as before. Where redefinition is used, however, we replace all redefined features inherited by a classifier with their new definitions before we form the overall union.  [This gives us a choice of replicating features if we explicitly redefine them but does not affect the fact that repeatedly inherited features are shared by default].
+
 
+
The semantics of inheritance and subtyping are discussed further in the definitions of Generalization and Class.  The redefinition of inherited elements is discussed in the definitions for Operation and Field.
+
 
+
 
+
== Specifications ==
+
  
 
{{Node
 
{{Node
| extends = Namespace
+
| extends = Type, Namespace
 
| description = A model element that defines a set of structural and behavioral features, e.g. an Interface or Class.
 
| description = A model element that defines a set of structural and behavioral features, e.g. an Interface or Class.
 
| references = [5, p. 2-14, Figure 2-5], [5, pp. 2-30, 2-61]
 
| references = [5, p. 2-14, Figure 2-5], [5, pp. 2-30, 2-61]
 
}}
 
}}
 
== Language mappings ==
 
 
Classifier is an abstract metaclass and has no direct mapping to most languages.  Specific types of classifiers (e.g., classes and interfaces), however, do have a direct mapping to corresponding language features.
 
In comparison to most programming languages (e.g., C++, Java, Eiffel), separately defined features with the same signature do not have the same identity in XCIL.  This allows us to distinguish repeated inheritance (inheritance of the same feature by more than one path) from the inheritance of independently defined features that happen to have the same signature.
 

Latest revision as of 18:44, 4 February 2015

A Classifier is a Type which may have Fields and/or Methods, such as a class, interface, or struct. They serve as templates for runtime instances, and may extend other classifiers.

Because languages differ in the semantics of specific subtypes of classifiers, XCSG provides the language-specific subtypes, but does not attempt to provide generic subtypes of Classifier; instead, the role of a classifier can be distinguished by its features: if it has only abstract methods, its role is likely that of an interface, if it has only concrete methods, then it is likely a class, if it is actually constructed and used, that can usually be seen from inspecting data flow (exceptions may include construction by injection frameworks or construction by means of reflection).

Specification

Metaclass Classifier
Extends TypeNamespace
Description A model element that defines a set of structural and behavioral features, e.g. an Interface or Class.
Direct Subkinds Java:Annotation, Java:Class, Java:Interface, C:Struct
All Superkinds Namespace, Type, Node, ModelElement
Specified In Edges
In Edge Predecessor Multiplicity Description
InvokedType DynamicCallSite Connects a DynamicCallSite or Invoke node to the declared type of the object whose Method is being invoked.
Invoke
Supertype Classifier Connects a Classifier to another Classifier that it extends.

Inherited From In Edge Predecessor Multiplicity Description
Type AliasedType TypeAlias Connects a TypeAlias to the Type or TypeAlias it was declared to duplicate.

ArrayElementType ArrayType 0..1 Connects an ArrayType to the Type of elements contained by arrays of that type.
C:CompletedBy OpaqueType 1 Connects an OpaqueType to the complete definition of the corresponding Type.
ReferencedType Pointer Connects a Pointer to the Type of the data pointed to.
Returns Function Connects a Function to the Type of its return value (which may be Void).
TypeOf Variable Links a Variable or DataFlow node to its Type

DataFlow (Node)
Specified Out Edges
Out Edge Successor Multiplicity Description
HasVariable ProgramVariable Links a Classifier or Package to one of its Variables.
InstanceVariable
Supertype Classifier Connects a Classifier to another Classifier that it extends.

Inherited From Out Edge Successor Multiplicity Description
Type TypeChecked InstanceOf Connects a Type (usually a Classifier) to an InstanceOf test.
Known Possible In Edges

Inherited From In Edge Predecessor Multiplicity Description
Node Contains Node 1 Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.
Known Possible Out Edges

Inherited From Out Edge Successor Multiplicity Description
Namespace HasVariable Variable Links a Classifier or Package to one of its Variables.
Node Contains Node Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.