LARA

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
inheritance [2008/02/04 16:28]
ersoy
inheritance [2008/02/04 16:29]
ersoy
Line 4: Line 4:
  
 Inheritance is not subtyping [1], but I will focus on subclassing that creates subclasses, and I will handle the useful exceptional cases (e.g. implementation inheritance) explicitly by providing some static guarantees. Inheritance is not subtyping [1], but I will focus on subclassing that creates subclasses, and I will handle the useful exceptional cases (e.g. implementation inheritance) explicitly by providing some static guarantees.
 +
  
  
Line 17: Line 18:
 {{inheritance.jpg}} {{inheritance.jpg}}
  
-Meyer [6], classified valid use of inheritance into 12 categories (can be seen in the tree above), and argued that any kind of inheritance that does not fall into one of these should not be used. Meyer'​s classification is problematic in a couple of aspects. First, he argues that IS-A relation can be used as a negative rule in the Popperian style to detect and reject inappropriate uses of inheritance,​ but not all the uses for which the relationship holds is appropriate. As a results, he tries to identify the appropriate uses of inheritace when IS-A relation holds, and fragments the classification redundantly. He does not give any convincing example, when IS-A relation holds between two classes and using iheritance is inappropriate. His only example is, MALE and FEMALE should not be subclasses of the PERSON class, if gender does not significantly matter within the system. However, existence of a class is an entirely different debate, and Meyer'​s classification does not prevent this use anyway. According to his classification,​ if there is an abstract PERSON class and two derived classes MALE and FEMALE, this can be categorized as "​subtype inheritance"​. His definition for subtype inheritance is, "​Subtype inheritance applies if A and B represent certain sets A' and B' of external objects such that B' is a subset of A' and the set modeled by any ther subtype heir of A is disjoint from B'. A must be deferred."​ Because, MALE and FEMALE model disjoint sets and are subsets of the set modeled by PERSON, this is an instance of subtype inheritance. My main point is, there is no need to fragment the classification with complicated definitions,​ when a rigorously defined IS-A relationship holds between two classes. The problem with Meyer'​s classification is, his definition of IS-A relation is too informal and heavily relies on natural language, which is inherently ambiguous . Some examples of this kind of ambiguity can be seen in [2].+Meyer [7], classified valid use of inheritance into 12 categories (can be seen in the tree above), and argued that any kind of inheritance that does not fall into one of these should not be used. Meyer'​s classification is problematic in a couple of aspects. First, he argues that IS-A relation can be used as a negative rule in the Popperian style to detect and reject inappropriate uses of inheritance,​ but not all the uses for which the relationship holds is appropriate. As a results, he tries to identify the appropriate uses of inheritace when IS-A relation holds, and fragments the classification redundantly. He does not give any convincing example, when IS-A relation holds between two classes and using iheritance is inappropriate. His only example is, MALE and FEMALE should not be subclasses of the PERSON class, if gender does not significantly matter within the system. However, existence of a class is an entirely different debate, and Meyer'​s classification does not prevent this use anyway. According to his classification,​ if there is an abstract PERSON class and two derived classes MALE and FEMALE, this can be categorized as "​subtype inheritance"​. His definition for subtype inheritance is, "​Subtype inheritance applies if A and B represent certain sets A' and B' of external objects such that B' is a subset of A' and the set modeled by any ther subtype heir of A is disjoint from B'. A must be deferred."​ Because, MALE and FEMALE model disjoint sets and are subsets of the set modeled by PERSON, this is an instance of subtype inheritance. My main point is, there is no need to fragment the classification with complicated definitions,​ when a rigorously defined IS-A relationship holds between two classes. The problem with Meyer'​s classification is, his definition of IS-A relation is too informal and heavily relies on natural language, which is inherently ambiguous . Some examples of this kind of ambiguity can be seen in [2].
  
-Meyer'​s informal IS-A rule of inheritance is "Do not make a class B inherit from a class A unless you can somehow make the argument that one can view every instance of B also an instance of A.". The notion of substitutability was first proposed by Liskov and Wing [5], and it was called "​behavioral subtyping"​. According to that definition, for B to be a behavioral subtype of A, its invariant must imply A's invariant, and its methods must preserve the behavior of A's methods, that is when contracts are inherited, preconditions cannot be strengthened and postconditions cannot be weakened. Leavens [4] formalized behavioral subtyping and fixed some problems with Liskov and Wing's definition. Comprehensive list of work on behavioral subtyping can be found in [4]. +Meyer'​s informal IS-A rule of inheritance is "Do not make a class B inherit from a class A unless you can somehow make the argument that one can view every instance of B also an instance of A.". The notion of substitutability was first proposed by Liskov and Wing [6], and it was called "​behavioral subtyping"​. According to that definition, for B to be a behavioral subtype of A, its invariant must imply A's invariant, and its methods must preserve the behavior of A's methods, that is when contracts are inherited, preconditions cannot be strengthened and postconditions cannot be weakened. Leavens ​and Naumann ​[5] formalized behavioral subtyping and fixed some problems with Liskov and Wing's definition. Comprehensive list of work on behavioral subtyping can be found in [5]. 
  
-Subsumption problem also arises in the context of knowledge representation. Taxonomies play a key role in conceptual modelling, and wrong uses of subsumption in taxonomies, makes models confusing, and difficult to integrate or reuse. Welty and Guarino [8], developed OntoClean for analysing ontologies based on formal, domain-independent properties of classes (the metaproperties) such as identity, unity, rigidity, and dependence. OntoClean allows designers to make assumptions about each property in the taxonomy and checks the consistency of each set of metaproperties. Rigorous analysis of the ontological meta-properties of taxonomic nodes lead to consistent usage of the subsumption relation.+Subsumption problem also arises in the context of knowledge representation. Taxonomies play a key role in conceptual modelling, and wrong uses of subsumption in taxonomies, makes models confusing, and difficult to integrate or reuse. Welty and Guarino [9], developed OntoClean for analysing ontologies based on formal, domain-independent properties of classes (the metaproperties) such as identity, unity, rigidity, and dependence. OntoClean allows designers to make assumptions about each property in the taxonomy and checks the consistency of each set of metaproperties. Rigorous analysis of the ontological meta-properties of taxonomic nodes lead to consistent usage of the subsumption relation.
  
 Another problem with Meyer'​s classification is, even though he says inheritance should only be used when IS-A relation holds between classes, he includes implementation inheritance in his classification. Just to include implementation inheritance,​ which actually represents "​is-implemented-in-terms-of"​ relation, he says there are different forms of "​is-a"​ and he modifies the definition of his IS-A relation. ​ Another problem with Meyer'​s classification is, even though he says inheritance should only be used when IS-A relation holds between classes, he includes implementation inheritance in his classification. Just to include implementation inheritance,​ which actually represents "​is-implemented-in-terms-of"​ relation, he says there are different forms of "​is-a"​ and he modifies the definition of his IS-A relation. ​