210 likes | 350 Views
Aspect-Oriented Software Development (AOSD) Tutorial #5. Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications. Today: Aspects Categories (contd.), LTL properties. Base system properties preservation guaranteed occasional
E N D
Aspect-Oriented Software Development (AOSD)Tutorial #5 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications
Today: Aspects Categories (contd.), LTL properties • Base system properties preservation • guaranteed • occasional • From natural language to Temporal Logic • Assume – guarantee aspects specification • Examples Aspect-Oriented Software Development (236608)
Example: Rational Exam (reminder) 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 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(); } Aspect-Oriented Software Development (236608)
Rational Exam System Properties -1 • “After a user answers a question, the system performs correctness check and prints out the result” Aspect-Oriented Software Development (236608)
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” Aspect-Oriented Software Development (236608)
Rational Exam – Properties Preservation Aspect-Oriented Software Development (236608)
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 Aspect-Oriented Software Development (236608)
From natural language to LTL Aspect-Oriented Software Development (236608)
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> Aspect-Oriented Software Development (236608)
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> Aspect-Oriented Software Development (236608)
Constraint 1 - formalized • Temporal Pattern = ? • Predicates: • Formula: Aspect-Oriented Software Development (236608)
Constraint 1 – formalized – contd. • Formalizing outcome action: • Predicates: • The whole formula: Aspect-Oriented Software Development (236608)
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> Aspect-Oriented Software Development (236608)
Constraint 2 - formalized • Temporal Pattern = ? • Predicates: • Formula: Aspect-Oriented Software Development (236608)
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; } } Aspect-Oriented Software Development (236608)
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(“…”); } Aspect-Oriented Software Development (236608)
Assume-guarantee spec. 1 – contd. Assumption: Guarantee: Aspect-Oriented Software Development (236608)
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); } Aspect-Oriented Software Development (236608)
Assume-guarantee spec. 2 – contd. Assumption: Guarantee: Aspect-Oriented Software Development (236608)
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()+")"); } Aspect-Oriented Software Development (236608)
Assume-guarantee spec. 2 – contd. Assumption: Guarantee: Aspect-Oriented Software Development (236608)