Surmounting the Complexity Constraints of Aspect ...

4 downloads 1000 Views 202KB Size Report
Technical Campus, Jalandhar, Punjab 144007, India. Abstract Aspect Oriented Programming is the extension of Object Oriented Programming, separating the ...
Surmounting the Complexity Constraints of Aspect Oriented Program Preeti Sikka1,* and Kulwant Kaur2 1 Ph. D. Scholar, Punjab Technical University, Punjab 144601, India. 2 School of Information Technology , Appejay Institute of Management Technical Campus, Jalandhar, Punjab 144007, India.

Abstract Aspect Oriented Programming is the extension of Object Oriented Programming, separating the cross cutting concern and making the code more clear and easy to understand with good maintainability and reusability. With this howling success it has added several complexities in debugging, maintaining the program. This paper is based on the idea that removing these complexities will make AOP as the better extension of OOP with no drawback. Dynamic Slicing succeeds in maintaining and debugging the Object Oriented Programs on less time. This paper explains aspect oriented concepts and finally concludes that AOP with the feature of slicing will bring the best in programming paradigm. Keywords: AOP (Aspect Oriented Programming), Dynamic Program Slicing, Aspects.

1. Introduction Aspect oriented programming succeeds to provide higher modularity level to the software system than provided by object oriented system. Aspect oriented programming has accomplished the goal of collecting the sprinkled code together and to keep it separately as an aspect. Doing so, AOP faces the problem in both structural and cognitive software complexity, software testability etc that affect the understandability, readability, testability and correctness of software in real world software projects[1]. Also analyzing the program needs more focus to search for an aspect. Dynamic slicing has been proved as a remarkable technique to analyze and debug the object oriented program within less cost and time. This paper concludes that slicing can be applied to gain the proper knowledge of the programs to find the scattered code and to solve other issues faced by AOP. *

corresponding author- [email protected]

E.S. 12 Civil Lines Jalandhar, Punjab 144001, India, Ph num: 09023364167

This paper will demonstrate the dynamic slicing in Aspect oriented program so that the advantages of AOP can be enjoyed without the concern of the problems attached with the complexity with cross cutting concern which can be handled by the program slicing technique. The structure of this paper is as follows: Section 2 gives the brief review of the features of AOP; Section 3 demonstrates the reduction in code after applying the dynamic program slicing on the program with an aspect and paper is finally concluded in section 4. 2. Aspect Oriented Programming OOP has a property of separate functionality with each class but in reality it is not. For example, exception handling is common to each class. If any of the common concern which is cross cutting the different classes is in a program, it can be put solely outside all the classes to make the code of the application clearer. The common concern here is known as cross cutting concern and is known as an aspect when put as a separate code. Another Example of cross cutting concern is ‘timing’ in a telecom application as it will crosscut the class ‘Customers’, ‘Calls’, and ‘Connections’ [2]. Aspect Oriented Program (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross cutting concerns [3]. Cross cutting concern is a code which has been related to different classes but actually not a part of these classes and so can be separated. It has been explained with the following example. If there is a University Management system with a task of admission process and management of university wants to create logs of every student who is taking admission in the University for the Transparency of admissions. Being related to every admission, it can be saved as an aspect because the same code for logging has to be repeated for each and every method in the university management system. Similarly other example of cross cutting concern is exception handling as it has to work with several methods in the system. Cross cutting concerns is a code which needs to be executed at several parts of a program. 2.1 Comparison between Object oriented programming (OOP) and Aspect Oriented Programming (AOP). Several points have been discussed which acquiesce the use of AOP. Parameters Modular

Problems with OOP Not completely Modular

Solved by AOP Completely Modular after putting the

cross cutting concern solely outside all classes Reusability

Programmers cannot reuse an object

Reusability is at greater extent.

independently of other objects since objects are connected to each other with a cross cutting concern[4] Related to

Program Slicing tools developed for

No such difficulty because of no

Program

object oriented language will be

cross cutting code within the

Slicing

difficult to maintain at the time of

modules.

Tools

language revision[5]

2.2 Features of Aspect Oriented Programming 2.2.1 Aspects: It is the module unit of the software designed for crosscutting concerns. It will include one or more of the other discussed features. 2.2.2 Join Points: It is a point in a program code where the concern is attached. Any well defined event example each method call at run time can be treated as different join point. Different types of join points are – 

Call: To call method or constructor



Execute: To invoke the individual constructor or a method



Get: to read the field of an object.



Set: To set the field of an object



Handler: To invoke an exception handler

2.2.3 Advices: It is a piece of code that gets executed when the join point is reached. For better understanding, Cross cutting concern is a set of advices. It can be of different types

Before advice: Advice is executed before a join point i.e. before actual method starts running.



After advice: Advice is executed after a join point.



Around advice: Advice that surrounds a join point example method invocation.



After returning advice: Advice used in 3.1 is ‘after returning advice’, it is different from after advice as it gets executed after the method returns successfully without throwing an exception.



After throwing advice: This advice gets executed if the method has been returned after throwing an exception.

Advice = Procedure + Condition (To execute the procedure) Specified by pointcuts Defined by Join Points Are Events 2.2.4 Point cuts: It is a subset of join points i.e. concern is attached at this point. It is shown in a Figure 1 with a call to one of the four methods of marks class with single int parameter. 2.2.5 Intertype Declarations: To allow the modification in program structure i.e. members of the class and relationship between class. 2.2.6 Weaving: It is aspect oriented compiler to compile the aspect oriented program 2.3 Constraints with AOP AOP has increased the modularity by adding aspects, but with the addition of the new feature it has also added the complexity to it. Besides the basic problems of complex structure the major issue in AOP is if an aspect has to be modified then would be difficult to find defects caused by an aspect modifying or preventing the behavior of other objects and aspects [5]. After doing a survey of programmers, several problems have been discussed due to an aspect in aspect oriented programs that affect the understandability, readability, testability and correctness of software in real world software projects [1]. The way to overcome this constraint is to apply program slicing on the code of AOP. 3. Program Slicing in AOP Root for various problems caused by separating the cross cutting concern as an aspect is its increased complexity provided to the program. If any slight change is done in cross cutting code then it might affect the other parts of application module which makes the maintenance of the program harder. For the same reason testing and debugging is harder in AOP. If this root-cause i.e. complexity is reduced then all related problems will themselves get diminished.

Program slicing is known as a remarkable technique used by programmers for decomposing the programs to minimal form preserving the program correctness [6]. Slicing reduces the program on which it is applied to a minimal form which still produces that behavior [7]. It will not affect the relevance of the code’s information. With these features if applied on aspects it will take out the part of the code relevant to the applied criteria hence reducing the complexity. Another issue, to convert non aspect oriented program to aspect oriented program, finding out the aspects in the existing software will be great challenge as it will require the large amount of time to analyze the program and the users with considerable amount of knowledge [8]. Program slicing if applied here will help to take out the related code which is scattered over the different classed. Dynamic slicing is to be given more importance to reduce complexity. Complexity in the control structure of programs is generated by the complexity in the intermingling of the threads. Dynamic slicing being able to isolate the unique thread computing the variable for the given inputs[9], if applied on AOP it will reduce its complex structure profoundly than applied simple slicing and make AOP as the better extension of OOP in all ways. 3.1 Example Consider an application to store the result of physics, chemistry and Mathematics of all the students. If marks is updated of any one of the subject then the percentage of a student has also be get updated. ‘Update’ will be a cross cutting concern here and it can be separated as a sole unit and termed as an aspect to make the other part of code cleaner. Considered an example on Java and AspectJ implementations [10] with slight modifications and shown that applying dynamic slicing on the code will reduce the lines of code of the program If the same code would be written in java then display.update() for updating the signal has to be called four times i.e. at the time of updating the marks of physics marks, chemistry marks, Mathematics marks and total marks but making this cross cutting concern as an aspect the same function is now applied only one time making the code completely modular. This has been shown that reduction in lines can help to overcome the debugging, testing etc as it has solved in OOP.

AspectJ Implementation

Base Code

Aspect Code + Dynamic Slicing w.r.t mi=2

1. 2. 3. 4.

Interface marks { Public inc_marks(int pi,int ci, int mi); }

1. 2. 3. 4.

Interface marks { Public inc_marks(int pi,int ci, int mi); }

5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.

Class marks implements increment{ Int p,c,m; Public int getp(){return p;} Public int getc(){return c;} Public int getm(){return m;} Public void setp(int p) { This.p=p; } Public void setc(int c) { This.c=c; }

5.

18. 19. 20. 21.

Public void setm(int m) { This.m=mi; }

22. 23. 24. 25. 26. 27.

Public void inc_marks (int pi, int ci, int mi) { p+=pi; c+=ci; m+=mi; }

28. 29. 30. 31. 32. 33. 34. 35. 36. 37.

class result implements increment { private marks res; public marks get_inc {return res;} Public void inc_marks (int pi, int ci, int mi) { Res.p+=pi; Res.c+=ci; Res.m+=mi; } } Point cut Join Points aspect update_result { pointcut change(): execution(void marks.setp(int))|| execution(void marks.setc(int))|| execution(void marks.setm(int))|| execution(void marks+.increment(int, int, int)); after() returning: change() { Display.update(); } Advice }

Class marks implements increment{ Int p,c,m; . . Public int getm(){return m;} . . . . . . . . Public void setm(int m) { This.m=mi; } Public void inc_marks (int pi, int ci, int mi) { . . m+=mi; } class result implements increment { private marks res; public marks get_inc {return res;} Public void inc_marks (int pi, int ci, int mi) { . . Res.m+=mi; } } aspect update_result { pointcut change(): execution(void marks.setp(int))|| execution(void marks.setc(int))|| execution(void marks.setm(int))|| execution(void marks+.increment(int, int, int)); after() returning: change() { Display.update(); } }

38. 39. 40. Aspect Code 41. 42. 43. 44.

6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40.

41. 42. 43. 44.

Figure 1. The AspectJ implementation of the marks classes with Decomposed code after applying the concept of Dynamic Slicing to it.

4. .Conclusion Paper has discussed the problem of complexities in AOP code especially when as aspect needs modification and finally concludes that dynamic slicing if applied to AOP will result in handling the complexity, making the AOP as a better extension of OOP in all ways.

References [1] Jeremy TB. An Examination of Aspect-Oriented Programming in Industry. Colorado State University Honors, PhD thesis. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.71.1086&rep=rep1&type=pdf on September 2013. (Accessed on September 2013) [2] Lopes C, Hilsdale E, Hugunin J, Kersten M, Kiczales G. Illustrations of Crosscutting. In: proceedings of the ECOOP; 2000 Workshop on Aspects and Dimensions of Concerns, doi=10.1.1.17.7943 [3] Sikka P, Kaur K. Program Slicing Techniques and their Need in Aspect Oriented Programming. International Journal of Computer Applications, Vol 70 - Number 3, DOI 10.5120/11941-7735 ; 2013,p. 11-14 [4] Ishio, T., Kusumoto, S., Inoue, K., “Debugging Support for Aspect Oriented Program Based on Program Slicing and Call Graph”, In 20th TEEE InternationalConference on S/W Maintenance [5] Ishio, T., Kusumoto, S., Inoue, K., “Program slicing tool for effective software evolution using aspect-oriented technique”, Proceedings of the 6th International Workshop on Principles of Software Evolution, ISBN: 0-7695-1903-2, 1-2 Sept. 2003, 3-12. (ICSM’04), ISBM 0-7695-2213-0, DOI 10.1109/ICSM.2004.1357802; sept 11’2004, p. 178-187 [6]Weiser M. Program Slicing. IEEE Transactions on software engineering, Vol. 10, Issue 4;1984, p. 352-357 [7] Weiser M. Program Slicing. ICSE '81 Proceedings of the 5th international conference on Software engineering, ISBN: 0-89791-146-6:1984, p. 439-449 [8] Livieri S, Ishio T, Kusumoto S, Inoue K, (Osaka Univ.). Planning an automated Aspect Mining Tool. IEICE Tech. Rep., vol. 105, no. 229, SS2005-38; Aug. 2005, p. 31-34 [9] Agarwal H, Horgam JR. Dynamic Program Slicing. In: Proceedings of the ACM SIGPLAN 1990 conference on Programming Language design and implementation, Vol 25, Issue 6, ISBN: 0-89791364-7, DOI: 10.1145/93542.93576;1990, p. 246-256 [10] Kiczales G, Mezini M. Aspect-Oriented Programming and Modular Reasoning. In: ICSE '05 Proceedings of the 27th international conference on Software engineering, ISBN: 1-58113-963-2, DOI: 10.1145/1062455.1062482; 2005, p. 49-58