Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects."— Presentation transcript:

1 Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects

2 Aspect-Oriented Software Development (236608) 2 Today: Categories of Aspects Categories - intuition Determining aspect category Safety and Liveness properties Base properties preservation (guaranteed and occasional) Examples

3 Aspect-Oriented Software Development (236608) 3 Aspect Categories – Intuition(1) Projection of S+A on S : the same as S (except for stuttering, maybe) A - spectative (computations tree of) S

4 Aspect-Oriented Software Development (236608) 4 Aspect Categories - Intuition(2) A - regulative Projection of S+A on S : Edges pruned S

5 Aspect-Oriented Software Development (236608) 5 Aspect Categories - Intuition(3) A – weakly invasive S Projection of S+A on S : Edges added

6 Aspect-Oriented Software Development (236608) 6 Aspect Categories - Intuition(4) A – strongly invasive S Projection of S+A on S : States added

7 Aspect-Oriented Software Development (236608) 7 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; } }

8 Aspect-Oriented Software Development (236608) 8 “Who am I?” Aspect 1: Positive quarter check. After each change in points, check whether they are in the positive quarter of the space pointcut movePoint … pointcut createPoint … 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( “…” ); }

9 Aspect-Oriented Software Development (236608) 9 “Who am I?” – contd. 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); }

10 Aspect-Oriented Software Development (236608) 10 “Who am I?” – contd. Aspect3: Adding names to points 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()+")"); }

11 Aspect-Oriented Software Development (236608) 11 “Who am I?” – contd. aspect RegistrationProtection { pointcut register(): call(void Registry.register(FigureElement)); pointcut canRegister(): withincode(static *FigureElement.make*(..)); declare error: register() && !canRegister(): "Illegal call " } Aspect 4: Contract enforcement. Only the factory methods can add an element to the registry of figure elements.

12 Aspect-Oriented Software Development (236608) 12 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

13 Aspect-Oriented Software Development (236608) 13 “Who am I?” – contd. Aspect 5: User-created exceptions logger (loggs the exceptions to a file) Aspect 6: Multiplication (provides the possibility to ask questions about multiplication)

14 Aspect-Oriented Software Development (236608) 14 “Who am I?” – contd. Aspect 7: Questions “normalization”. After a question is created, reduces the fractions appearing in it. Aspect 8: Age restriction. Only students under age 8 can do the exam

15 Aspect-Oriented Software Development (236608) 15 “Who am I?” – contd. Aspect 9: Grading aspect – during the exam, the percentage of the correct answers is counted. After the exam is finished, the grade is stored. Aspect 10: After the grading aspect is added to the system, the teacher is given a possibility to give a factor to the students.

16 Aspect-Oriented Software Development (236608) 16 Safety and Liveness Properties Safety property – “Bad things do not happen”: ψ → G φ (“at every state φ holds”) Liveness property – “Good things happen”. Every property that is not safety. For example, F φ (“φ holds at some future state”) [LTL past formula φ holds at state s iff …… “good” computation prefix (satisfies φ) state s includes s !

17 Aspect-Oriented Software Development (236608) 17 Examples : Safety and Liveness “If a message is sent, it will be received” “ Passwords are only sent encrypted” “Every received message is immediately processed”

18 Aspect-Oriented Software Development (236608) 18 Examples : Safety and Liveness (2) “The semaphore is free infinitely many times during each computation” “When the computation is finished, the system becomes idle, and stays idle forever” “Login is permitted only if the password has been verified”

19 Aspect-Oriented Software Development (236608) 19 Base Properties Preservation?(1) p p, q q q, t q t p, t φ 1 = G (p → X q) φ 2 = G (r → X t) join-points: r = true r, q, t r t r r r Spectative aspect; “X” properties

20 Aspect-Oriented Software Development (236608) 20 Base Properties Preservation(2) p p, r q q p, t φ 1 = G (p → F q) φ 2 = G (r → F t) r q r t p Regulative aspect; general liveness properties advice effect

21 Aspect-Oriented Software Development (236608) 21 Rational Exam System Properties “After a user answers a question, the system performs correctness check and prints out the result” “If an answer is a and the arguments - r 1 and r 2, the correctness check will result in “true” iff a = r 1 + r 2 ”

22 Aspect-Oriented Software Development (236608) 22 Rational Exam – Properties Preservation φ 1 = G( ((getAnswer()= a) ⋀ (a≠null)) → F( checkAnswer(a,result) ⋀ (F print(checkAnswer(a,result))))) φ 2 =G ( (checkAnswer(a,res)→(res=r 1 + r 2 )) ⋀ (checkAnswer(a, res)↔(a=res))) φ1φ1 φ2φ2 Exceptions logging Multiplication Normalization Age restriction Grading Factor


Download ppt "Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects."

Similar presentations


Ads by Google