90 likes | 221 Views
Multiple to single inheritance transformation June 15th, 2004. M. Dao , M. Huchard, T. Libourel, A. Pons, J. Villerd. Multiple inheritance: a new birth?. OO programming languages and MI: "good" implementation in not so popular languages: Eiffel, CLOS, …
E N D
Multiple to singleinheritancetransformationJune 15th, 2004 M. Dao, M. Huchard, T. Libourel, A. Pons, J. Villerd
Multiple inheritance: a new birth? • OO programming languages and MI: • "good" implementation in not so popular languages: Eiffel, CLOS, … • "bad" implementation in once popular languages: C++, …? • "no" implementation in today popular languages: Java (MI interfaces though), C#, …? • Not much excitement about MI lately, but… • …the modelling era has begun! • When you model, for instance in UML, you can use MI (almost) without moderation
MI to SI transformation • High-level MI models may eventually need to be transformed into SI models ("popular" OO languages, for instance) • Two possible approaches (among others?) • "combinatorial": cut inheritance links to obtain SI • need to duplicate class properties • how to choose those inheritance links • based on inheritance metrics (Roume 02) • "semantic": classify MI situations and transform MI into SI • use UML annotations to precise different MI situations • apply the "most appropriate" inheritance transformation
UML inheritance annotations • Discriminators allow to group inheritance links that share a same semantic • Constraints on subsets of instances of a class: complete, disjoint, incomplete, overlapping • We propose new constraints: • concurrent (special case of overlapping) • successive, exclusive (special case of disjoint) • combined • alternative
UML inheritance annotations Discriminators Constraints Employee {disjoint,complete} {disjoint,incomplete} :status :pension UnvestedEmployee SalariedEmployee HourlyEmployee VestedEmployee ExemptEmployee VestedExemptEmployee
MI transformations • Duplication • cut one inheritance link and duplicate formerly inherited properties in the subclass • Nested generalizations • create a class for each possible MI situation • Direct link • make the leaf class directly inherit from root class • Role aggregation • replace one MI link by an aggregation • Class merge • replace all classes with one
Example of transformation Employee {disjoint,complete} {disjoint,incomplete} :status :pension UnvestedEmployee HourlyEmployee SalariedEmployee VestedEmployee ExemptEmployee VestedExemptEmployee
The right transformation for the right inheritance situation • Our proposition: • elaborate a list of possible MI "situations" based on UML extended annotations and other criteria (size, symmetry, etc.) • for each situation, propose a suitable MI transformation • Examples • role aggregation transformation might be used with complete constraint: the structure will not evolve • direct link transformation might be used when symmetry is important for example in the case of the alternative constraint
Perspectives • elaborate a list of MI situations as complete as possible • a situation might be a subsituation of another: classification • try and find a most appropriate MI transformation for each situation • difficulties: • be able to automatically detect MI situations • different MI situations may overlap • order of transformations? • use of a model transformation language? • study an "hybrid" approach (combinatorial and semantic)?