A Modular Aspect-Oriented Programming Approach of Join Point Interfaces
Total Page:16
File Type:pdf, Size:1020Kb
(IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 10, No. 8, 2019 A Modular Aspect-Oriented Programming Approach of Join Point Interfaces Cristian Vidal1*, Erika Madariaga2*, Claudia Jimenez´ 3*, and Luis Carter4* 1Departamento de Administracion,´ Facultad de Econom´ıa y Administracion,´ Universidad Catolica´ del Norte, Antofagasta, Chile, 2Ingenier´ıa Informatica,´ Facultad de Ingenier´ıa, Ciencia y Tecnolog´ıa, Universidad Bernardo O’Higgins, Santiago, Chile, 3Ingenier´ıa Civil Informatica,´ Escuela de Ingenier´ıa, Universidad Vina˜ del Mar, Vina˜ del Mar, Chile, 4Ingenier´ıa Civil Industrial, Facultad de Ingenier´ıa, Universidad Autonoma´ de Chile, Chile, Abstract—This paper describes and analyzes the main differ- a class should encapsulate only one responsibility. This rep- ences and advantages of the Join Point Interfaces (JPI) as an resents a fundamental principle of modularization and object- Aspect-Oriented Programming (AOP) approach for the modular oriented programming [6]. software production concerning the standard aspect-oriented pro- gramming methodology for Java (AspectJ) to propose a structural Fig. 1 shows a diagram of UML use cases that repre- modeling approach looking for modular software solutions. Using sents a system and two cases of use that are examples of a Software Engineering point-of-view, we highlight the relevance cross-concerns, usually present in software systems: use cases of structural and conceptual design for JPI software applications. ‘Logging’ and ‘Authentication’. Note that Jacobson [7] [8], We model and implement a classic example of AOP using AspectJ and Vidal et al. [2] indicate the use of ‘extends’ associations and JPI as an application example to review their main difference between use cases that represent cross-concerns and base-use and highlight the JPI consistency between products (models cases. In traditional software systems, it is common that before and code). Our proposal of UML JPI class diagrams allows the definition of oblivious classes which know about their JPI acting, the user must authenticate, and if such authentication connections, an essential element to adapt and transform tradition does not occur, the action does not proceed. Besides, it is usual like-AspectJ AOP solutions to their JPI version. Thus, for the for current information systems to keep a record of the actions modular software production and education, JPI seems an ideal performed by their users. In this context, Fig. 2 presents a software development approach. traditional UML class diagram for the example system of Fig. 1. Keywords—Aspect-Oriented Programming; AspectJ; JPI; class diagrams; UML Fig. 2 shows two classes, Class1 and Class2, with a one-to-many association. Each class has two attributes and four methods. We can appreciate that both classes present the methods A (..) and B (..), that is, Register Actions and I. INTRODUCTION Authenticate. Assuming that the functionalities and associated behavior of the methods A(..) and B(..) are not specific to The methodology of Aspect-Oriented Programming (AOP) Class1 and Class2, and how these functionalities cannot be [1] allows to encapsulate or modularize the so-called “non- represented in independent classes so that Class1 and Class2 modularizable cross-concerns” by classical programming respect the principle of only responsibility, then methods A(..) methodologies such as object-oriented programming and struc- and B(..) are examples of cross-concerns. tured programming. The cross-functionalities are functions spread as part of the modules such as in the methods Table I presents the Java code associated with the UML of classes mixing their steps and nature. In this way, the class diagram of Fig. 2. As can be seen in both classes, public cross-functionalities represent non-modularizable functional methods explicitly invoke the execution of methods A(..) and elements by traditional software development methodologies B(..) which does not correspond to the responsibility nature like structured and object-oriented software development. We of public methods of Class1 and Class2, respectively. That is, talk of aspect-oriented software development given the adap- neither the classes nor the methods of this example respect the tation of other phases in the software development process to principle of sole responsibility. encapsulate the so-called cross-concerns. Such as Kiczales et al. [1] pointed out, classic or traditional AOP permits the elimination of cross-concerns in classes The users’ authentication and registration or log of their of object-oriented software systems modularizing them as actions are classic examples of cross-concerns [2] [3] [4]. aspects. However, as Bodden [9] points out, Instroza et al. [10], By modularizing cross-concerns of an object-oriented software and Bodden et al. [11], traditional AOP Aspect-style does not system, classes and their methods can respect the single- permit achieving a complete modularization for the existence responsibility principle [5]), that is, classes and their methods of implicit dependencies between aspects and classes. For own and know their function and well-defined purpose. Thus, getting software products with greater modularity, the works consistency should exist in the behavior of classes’ methods of [9] [10] [11] present Join Point Interfaces (JPI) to eliminate which do not presents actions out of their primary objective. implicit dependencies between classes and aspects of classic In summary, the principle of single-responsibility states that AOP AspectJ-style. *Corresponding author Considering the mentioned JPI benefits for developing www.ijacsa.thesai.org 569 j P a g e (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 10, No. 8, 2019 Fig. 1. Example of Cross-Concern for Logging the Actions and Authenticating in a Use Cases Diagram of a System. Fig. 2. Example of UML Class Diagram with Cross-Concerns. TABLE I. JAVA EXAMPLE WITH CROSS-CONCERNS. public class Class1 f public class Class2 f public <type>attribute1Class1; public <type>attribute1Class2; public <type>attribute2Class1; public <type>attribute2Class2; public <type>action1Class1([Arg1,., ArgN])f public <type>action1Class2([Arg1,., ArgN])f authentication(..); authentication(..); ... ... logging(..); logging(..); g g public <type>action2Class1([Arg1,., ArgN])f public <type>action2Class2([Arg1,., ArgN])f authentication(..) ; authentication(..); ... ... logging(..); logging(..); g g g g modular software, the main objective of this article is to apply propose and exemplify a UML class diagram for JPI solu- JPI concepts on a base example to demonstrate and describe tions. Finally, conclusions and future research work regarding its practical advantages for getting modular aspect-oriented behavioral modeling ideas using UML sequence diagrams for software solutions without implicit dependencies. Moreover, JPI solutions. this article proposes an approach for the structural modeling of JPI solutions along with gives the bases for future research II. RELATED WORKS for behavioral modeling of JPI solutions. Different works about AOP applications and extensions This work organizes as follows: next section summarizes already exist such us [12] and [13] which define formal related works. Section 3 presents and exemplifies the AspectJ rules to specify AOP solutions and [14] that uses an AOP and JPI aspect-oriented programming approaches. Section 4 framework to monitor the run-time state and behavior of describes and exemplifies UML class diagrams along with to software applications. The works of [9] [10] and [11] are www.ijacsa.thesai.org 570 j P a g e (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 10, No. 8, 2019 bases and programming background of the JPI framework for Table II presents the AOP AspectJ code solution for the building AOP solutions. The work of [15] represent one of example code of Fig. 3. As shown in this figure, the principle the first article to describe and exemplify JPI modeling ideas. of sole responsibility is respected in Class1 and Class2 classes. This article describe an exemplify a more precised and detailed In this example, the methods, methods action1Class1(..) structural modeling approach for JPI solutions which represent and action2Class1(..), as well as action1Class2(..) and ac- advances to look for a complete JPI software development tion2Class2(..), of the classes Class1 and Class2 respectively, process. are oblivious concerning the inclusion of aspects behavior. This ingenuity of the advised methods is problematic for III. ASPECT-ORIENTED PROGRAMMING methods that must preserve intact their original behavior. That represents one of the implicit dependencies between This section summarizes AspectJ and JPI AOP styles. classes and previously mentioned aspects. In the same way, if the signature of one of the public methods of Class1 or A. AspectJ-Style AOP Class2 changed, potentially Aspect1 and Aspect2 would not be Kiczales et al. [1] argue that the aspects, advice units, intro- effective, that is, there would be no join point, and besides, no ductions, relations between data-types, join points, and point- compilation errors exist. The following subsection describes cuts represent relevant characteristics of traditional AspectJ- the JPI approach proposed by [10] and [11] to look for like AOP. Also, there is a difference between base elements eliminating these dependencies between aspects and classes. and aspects, which are usually