aspect-oriented software development (aosd) tutorial #5 categories of aspects – contd.; ltl...

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

Post on 20-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

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

Aspect-Oriented Software Development (AOSD)

Tutorial #5

Categories of Aspects – contd.;

LTL properties formalization;

Assume – guarantee specifications

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

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

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

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

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

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”

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

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”

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

Aspect-Oriented Software Development (236608)

6

Rational Exam – Properties Preservation

Category φ1 φ2

Exceptions logging

Multiplication

Normalization

Age restriction

Grading

Factor

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

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

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

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

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

Aspect-Oriented Software Development (236608)

9

Example – Toll System (Reminder)

<Aspect name="ResponseTime"> <Requirement id="1"> The system needs to react in-time in order to: <Requirement id="1.1">read the gizmo identifier; </Requirement> <Requirement id="1.2">turn on the light (to green or yellow);

</Requirement> <Requirement id="1.3">display the amount to be paid; </Requirement>

<Requirement id="1.4">photograph the plate number from the rear;</Requirement>

<Requirement id="1.5">sound the alarm; </Requirement> <Requirement id="1.6">respond to gizmo activation and

reactivation.</Requirement> </Requirement> </Aspect>

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

Aspect-Oriented Software Development (236608)

10

Toll System - Constraint 1

<Requirement aspect="ResponseTime" id="1.1">

<Constraint action="enforce" operator="between">

<Requirement viewpoint="Vehicle" id="1" /> <Requirement viewpoint="Vehicle" id="2" />

</Constraint>

<Outcome action="satisfied"> <Requirement viewpoint="Gizmo" id="1“ children="include" />

</Outcome>

</Requirement>

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

Aspect-Oriented Software Development (236608)

11

Constraint 1 - formalized

• Temporal Pattern = ?

• Predicates:

• Formula:

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

Aspect-Oriented Software Development (236608)

12

Constraint 1 – formalized – contd.

• Formalizing outcome action:

• Predicates:

• The whole formula:

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

Aspect-Oriented Software Development (236608)

13

Toll System - Constraint 2

<Requirement aspect="ResponseTime" id="1.2">

<Constraint action="enforce" operator="between">

<Requirement viewpoint="Gizmo" id="1" children="include" /> <Requirement viewpoint="Vehicle" id="3" />

</Constraint>

<Outcome action="satisfied" operator = "XOR" > <Requirement viewpoint=“PayingToll" id="1" /> <Requirement viewpoint=“PayingToll" id=“2" />

</Outcome>

</Requirement>

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

Aspect-Oriented Software Development (236608)

14

Constraint 2 - formalized

• Temporal Pattern = ?

• Predicates:

• Formula:

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

Aspect-Oriented Software Development (236608)

15

Example Class: Point - reminderclass 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; }}

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

Aspect-Oriented Software Development (236608)

16

Assume-guarantee spec. 1Aspect 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(“…”); }

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

Aspect-Oriented Software Development (236608)

17

Assume-guarantee spec. 1 – contd.Assumption:

Guarantee:

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

Aspect-Oriented Software Development (236608)

18

Assume-guarantee spec. 2Aspect 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); }

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

Aspect-Oriented Software Development (236608)

19

Assume-guarantee spec. 2 – contd.Assumption:

Guarantee:

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

Aspect-Oriented Software Development (236608)

20

Assume-guarantee spec. 3Aspect3: 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()+")");}

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

Aspect-Oriented Software Development (236608)

21

Assume-guarantee spec. 2 – contd.Assumption:

Guarantee: