Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects –...

download Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications

of 21

  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    212
  • download

    0

Embed Size (px)

Transcript of Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects –...

  • Slide 1
  • Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects contd.; LTL properties formalization; Assume guarantee specifications
  • Slide 2
  • Aspect-Oriented Software Development (236608) 2 Today: Aspects Categories (contd.), LTL properties Base system properties preservation guaranteed occasional From natural language to Temporal Logic Assume guarantee aspects specification Examples
  • Slide 3
  • Aspect-Oriented Software Development (236608) 3 Example: Rational Exam (reminder) private void doExam() { while (true) { r1 = randomRational(); r2 = randomRational(); result = r1.add(r2); answer = getAnswer(r1, r2); if (answer == null) break; checkAnswer(answer, result); } public static void main(String[] args) { RationalExam exam = new RationalExam(); exam.doExam(); } The system generates and checks online exams for students with simple arithmetic exercises for fractions RationalExam class: initiates exams, generates questions, accepts answers, checks answers
  • Slide 4
  • Aspect-Oriented Software Development (236608) 4 Rational Exam System Properties -1 After a user answers a question, the system performs correctness check and prints out the result
  • Slide 5
  • Aspect-Oriented Software Development (236608) 5 Rational Exam System Properties -2 If an answer is a and the fractions in the question r1 and r2, the correctness check will result in true iff a = r1 + r2
  • Slide 6
  • Aspect-Oriented Software Development (236608) 6 Rational Exam Properties Preservation Category11 22 Exceptions logging Multiplication Normalization Age restriction Grading Factor
  • Slide 7
  • Aspect-Oriented Software Development (236608) 7 From natural language to LTL In this example: Specification of events in the system and their relations Examples from the ontology of ARCADE temporal patterns: match patterns with temporal logic formulas
  • Slide 8
  • Aspect-Oriented Software Development (236608) 8 From natural language to LTL Temporal pattern (events)Temporal logic E between A and B A during B A before B, B only after A A leads to B C on A and B
  • Slide 9
  • Aspect-Oriented Software Development (236608) 9 Example Toll System (Reminder) The system needs to react in-time in order to: read the gizmo identifier; turn on the light (to green or yellow); display the amount to be paid; photograph the plate number from the rear; sound the alarm; respond to gizmo activation and reactivation.
  • Slide 10
  • Aspect-Oriented Software Development (236608) 10 Toll System - Constraint 1
  • Slide 11
  • Aspect-Oriented Software Development (236608) 11 Constraint 1 - formalized Temporal Pattern = ? Predicates: Formula:
  • Slide 12
  • Aspect-Oriented Software Development (236608) 12 Constraint 1 formalized contd. Formalizing outcome action: Predicates: The whole formula:
  • Slide 13
  • Aspect-Oriented Software Development (236608) 13 Toll System - Constraint 2
  • Slide 14
  • Aspect-Oriented Software Development (236608) 14 Constraint 2 - formalized Temporal Pattern = ? Predicates: Formula:
  • Slide 15
  • Aspect-Oriented Software Development (236608) 15 Example Class: Point - reminder class Point { private int x, y; public Point(int x, int y) { this.x = x; this.y = y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void MoveTo(Point p) {setX(p.x); setY(p.y); } public int getX() { return x; } public int getY() { return y; } }
  • Slide 16
  • Aspect-Oriented Software Development (236608) 16 Assume-guarantee spec. 1 Aspect 1: Positive quarter check. After each change in points, check whether they are in the positive quarter of the space pointcut movePoint //calls to setX(), setY() pointcut createPoint //calls to Point(..) after(Point pt, int newArg) returning(): movePoint(pt, newArg) { if( newArg < 0) System.out.println( ); } after(int x, int y) returning(): createPoint(x, y) { if( x < 0 || y < 0) System.out.println( ); }
  • Slide 17
  • Aspect-Oriented Software Development (236608) 17 Assume-guarantee spec. 1 contd. Assumption: Guarantee:
  • Slide 18
  • Aspect-Oriented Software Development (236608) 18 Assume-guarantee spec. 2 Aspect 2: Positive quarter enforce. Make sure all the points are in the positive quarter of the space void around(Point pt, int newArg): movePoint(pt, newArg) { if( newArg >= 0) proceed(pt, newArg); else System.out.println( ); } Point around(int x, int y) : createPoint(x, y) { if( x < 0) { x=0; System.out.println( );} if( y < 0) { y=0; System.out.println( );} proceed(x,y); }
  • Slide 19
  • Aspect-Oriented Software Development (236608) 19 Assume-guarantee spec. 2 contd. Assumption: Guarantee:
  • Slide 20
  • Aspect-Oriented Software Development (236608) 20 Assume-guarantee spec. 3 Aspect3: Adding names to points; tracing movements private String Point.name = ""; public String Point.getName() {return name;} public void Point.setName(String newName) {name = newName;} pointcut moved(Point pt): target(pt) && (call(void setX(int)) || call(void setY(int))); after(Point pt) returning: moved (pt) { System.out.println("Point "+pt.getName()+" moved to ("+pt.getX()+","+pt.getY()+")"); }
  • Slide 21
  • Aspect-Oriented Software Development (236608) 21 Assume-guarantee spec. 2 contd. Assumption: Guarantee: