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( “…” ); } spectative

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); } weakly invasive!

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()+")"); } spectative

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. regulative

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) spectative strongly invasive

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 weakly invasive regulative

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. spectative weakly invasive

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 ! ψ, φ – past LTL formulas

17 Aspect-Oriented Software Development (236608) 17 Examples : Safety and Liveness “If a message is sent, it will be received” G(msg_send → F msg_rec) => Liveness “ Passwords are only sent encrypted” G(psw_sent → encrypted) => Safety “Every received message is immediately processed” G(msg_rec → X msg_proc) => Liveness

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


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

Similar presentations


Ads by Google