SlideServe
Menu
Préférences
© SlideServe · v2026

Inheritance Anomalies

ilar avatar
12 diapositives · 327 Views · Sep 19, 2014

Inheritance Anomalies. Synchronization of concurrent objects and inheritance . Key paper: [Matsuoka93] Analysis of Inheritance Anomalies in OOPL.

Inheritance Anomalies - slide 1
01 / 12Inheritance Anomalies
1 / 17

Télécharger la présentation

Inheritance Anomalies
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Inheritance Anomalies • Synchronization of concurrent objects and inheritance. • Key paper: [Matsuoka93] Analysis of Inheritance Anomalies in OOPL. • “When coding a base class (…) the code related to concurrency control cannot be effectively inherited and/or refined in a subclass without non-trivial redefinitions of the methods implementation.” [C. Lopes PhD] COM3362 Winter'02

  2. Separation of core and synchronization behaviors (1) • Synchronization constraint: • In a certain state an object can accept only certain methods to maintain its internal integrity. Bounded-Buffer object: • Get(): if buffer not empty. • Put(): if buffer not full. COM3362 Winter'02

  3. Separation of core and synchronization behaviors (2) • Synchronization code: • Portion of code where the synchronization behavior is controlled. • It must always be consistent with the synchronization constraint. COM3362 Winter'02

  4. When are Inheritance Anomalies found? • Partition of acceptable states (Get2()) • History-only sensitiveness of acceptable states (Gget(), DoubleClick() ) • Modification of acceptable states. (Lock) COM3362 Winter'02

  5. Core behavior Synchronization behavior Other concern- related behavior How does AOP helps? AO program OO program COM3362 Winter'02

  6. LeftClick(); RightClick(); LeftPress(); LeftRelease(); LeftClick(); RightClick(); LeftPress(); LeftRelease(); History-only related behavior Mouse Mouse MouseWDc MouseWDc 2-button 2-button Wheel Wheel 3-button 3-button WheelClick(); WheelRollUp(); WheelRollDown(); WheelClick(); WheelRollUp(); WheelRollDown(); MiddleClick(); MiddleClick(); Double click No inheritance anomalies! COM3362 Winter'02

  7. Double clicks (1) aspect DoubleClick { private String MouseWDc.prevOp; private String MouseWDc.get_prevOp() { return prevOp; } privatevoid MouseWDc.set_prevOp(String op) {prevOp=op;} // very specific pointcuts allow us keeping the advice simple pointcut pc(MouseWDc m): (call(* *(..))) && (!call(* get*(..))) && (!call(* set*(..))) && target(m) && !within(DoubleClick); pointcut pcTB(TwoButton m): call(* *Click(..)) && target(m); pointcut pcWM(WheelMouse m): (call(* LeftClick(..)) || call(* WheelClick(..))) && target(m); after(MouseWDc m): pc(m) { // common behavior for doubleclicks String curr_op = thisJoinPoint.getSignature().toShortString(); if(m.get_prevOp()!=null && m.get_prevOp().equals(curr_op)) { if (curr_op.indexOf("LeftClick")!=-1) System.out.println("Double LeftClick detected"); } else { if ((curr_op.indexOf("LeftClick")==-1) && (curr_op.indexOf("RightClick")==-1) && (curr_op.indexOf("WheelClick")==-1)) { m.set_prevOp(curr_op); } } } COM3362 Winter'02

  8. Double clicks (2) after (TwoButton m): pcTB(m) { // exclusive behavior for TwoButton Mice String curr_op = thisJoinPoint.getSignature().toShortString(); if(m.get_prevOp()!=null && m.get_prevOp().equals(curr_op)) { if (curr_op.indexOf("RightClick")!=-1) System.out.println("Double RightClick detected"); } else { m.set_prevOp(curr_op); } } after (WheelMouse m): pcWM(m) { // exclusive behavior for Wheel Mice String curr_op = thisJoinPoint.getSignature().toShortString(); if(m.get_prevOp()!=null && m.get_prevOp().equals(curr_op)) { if (curr_op.indexOf("WheelClick")!=-1) System.out.println("Double WheelClick detected"); } else { m.set_prevOp(curr_op); } } } // end of aspect COM3362 Winter'02

  9. Advantages of using AOP • No code tangling caused by synchronization concerns • No inheritance anomalies associated with concurrency ! • Higher level of reusability. COM3362 Winter'02

  10. Solutions found • DJ Visitor to solve the Mouse problem. • Using AspectJ: • Very specific pointcuts => simpler advice. • General pointcuts => more elaborated advice • Abstract aspects =>higher degree of reusability • Too many abstraction levels make code difficult to follow. • Open classes => incremental approach COM3362 Winter'02

  11. Comments • Solutions are very dependent on the parser for the simulation language. • Use AOP design has hardly been used instead of OOP design. COM3362 Winter'02

  12. Summary of best solutions • Building from scratch: • Use of AOP design and open classes • Using AspectJ: • Use abstract aspects for reusability • Use fine grained definition of pointcuts COM3362 Winter'02