An Analysis of Aspect Oriented Programming with AspectJ

Size: px
Start display at page:

Download "An Analysis of Aspect Oriented Programming with AspectJ"

Transcription

1 An Analysis of Aspect Oriented Programming with AspectJ Advisor: Dr. Jehan Francois Paris Professor Department of Computer Science University of Houston Submitted by: Jay Gattani Department of Computer Science University of Houston CHAPTERS The Object Oriented Paradigm 1 OOP highlights and benefits 1 OOP and Separation of Concern 3 What about global concerns? 3 Aspect Oriented Programming Approach 5 Crosscutting global concerns 5 AOP solution for crosscutting concerns 5 What does AOP achieve? 6 AOP and OOP: friends or foes 8 Introduction to AspectJ 9 AOP insertion through AspectJ 9 The Join-Point model 9 Important AOP Definitions 10 Exposing context at a join-point with pointcuts 13 Named pointcuts 15 call versus execution 16 thisjoinpoint keyword 17 Wrapping it all in an Aspect 17 Case study: Development Aspects 19 Aspects to handle tracing concerns 19 Aspects to handle logging & profiling 25 Pitfalls in AspectJ 29 The infinite loop problem 29 Introductions: Problems in disguise 30 Conclusion 31 References 32 University of Houston Page 1 of 33

2 1. The Object Oriented Paradigm 1.1 OOP highlights and benefits Object Oriented Progamming is the dominant programming methodology that is being used in all forms of software Development today. The main focus of OOP is to overcome the problems of structured programming by using the various OO-principles such as encapsulation and polymorphism towards the development of software systems that are more robust, reliable and extensible. Object technology, including OO methodologies, analysis and design tools, and OO programming language, reduces the complexity in writing and maintaining complex applications such as distributed applications and graphical userinterfaces. Various design methodologies and patterns have evolved since the birth of OOP to aid in the design of a system that is extensible and easy to maintain. The main focus of OOP is to find a modular solution for a problem by breaking down the s/w system to be built into a collection of objects that encapsulate state and behavior. These objects exchange messages for communication across a well-defined interface and collectively cooperate to define and provide the functionality required. Inheritance and polymorphism provide the mechanism to organize and design the system in a hierarchy of classes by shifting the commonalities higher up in the hierarchy in the form of abstract classes and interfaces and shifting the distinct and specific features to concrete classes concentrated towards the lower end of the architecture. Principles such as Open-Close Principle 1 (OCP) and Dependency Inversion Principle 2 (DIP) provide a systematic mechanism to maintain the dependency between classes higher up in the hierarchy, thus reducing the coupling between the concrete classes and keeping the system as loosely coupled as possible. This adds to the maintainability and extensibility of the system and the resilience of the system to changes. Figure 1: Amount and location of code to handle XML parsing in org.apache.tomcat [1]. The vertical bars depict individual modules and the red line depicts the code for XML parsing. 1 OCP states that Software entities should be open to extension and closed to modification 2 DIP states that High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions. University of Houston Page 2 of 33

3 Advancement in OOP have improved the ability of a software developer to achieve clear separation of concerns thus giving him the ability to analyze, identify and encapsulate cohesive functionality in the form of a well defined structure of classes. This leads to a separation of concern based analysis and design leading to a s/w solution comprising of a number of cohesive modules working in correlation towards the achievement of the final goal. 1.2 OOP and Separation of Concerns OOP undoubtedly is an efficient approach towards effectively handling local concerns. Local concerns are the concerns that are vertical in nature and can be encapsulate into a system of classes and object. The following figure depicts the amount and location of code to handle XML parsing in org.apache.tomcat: Figure [1] is a typical example of a vertical concern that can be identified easily during the design phase and a solution can be obtained in the form of a class or a system of classes that collectively provide a solution that addresses the concern in a modular manner. The code to address this issue is centralized and encapsulated within a finite and small number of classes leading to a much more modular and extensible solution. Most of the basic functional requirements of the system can be broken down into localized concerns and an OOP approach could be used to provide a solution to address these concerns. 1.3 What about Global Concerns? There are certain concerns within a system that are global in nature. These are the concerns that cut orthogonally through a system and are subparts of a set of requirements. These concerns do not fit naturally into a single s/w module or related modules but are intertwined with a number Figure 2: Amount and location of code to handle Logging in org.apache.tomcat [1]. The vertical bars depict individual modules and the red line depicts the code for Logging. University of Houston Page 3 of 33

4 of unrelated modules and do not naturally fit in the paradigms of modular design. Just to elaborate a little more on global concerns, the figure above shows a graphical representation of the various modules in org.apache.tomcat where the red lines depict the amount and location of code that handles logging. The code for logging is not centralized within a class or a module but permeates throughout the system cutting it orthogonally. Hence there is duplication of code to address the same concern at a number of points within the system. This leads to the following side effects: Code redundancy: Multiple pieces of code providing the same functionality permeated throughout the system. Difficult to change: The code cannot be changed easily as it would require code changes at multiple places ranging a large number of modules and classes. Moreover, locating the points where the changes have to be made is a time consuming issue since the code is not centralized. Over time, as the system evolves, inconsistencies might arise due to inconsistent code changes. Less Maintainability: Code becomes less maintainable and cannot be evolved easily. It becomes difficult to grasp and understand. Less Extensibility: The entire code becomes less extensible due to code duplication to handle the global concerns. Difficult to test: Multiple test-cases for the same functionality at various points. Thus, OOP fails to provide a robust and extensible solution to handle these global concerns. There are a number of concerns such as logging, error-handling, security, transaction tracing etc. which are global in nature and cut through multiple elements in the system. These global concerns present a serious issue as they cannot be effectively handled within the OOP paradigm. This is one of the major pitfalls of OOP its inability to handle global concerns in an effective manner. University of Houston Page 4 of 33

5 2. Aspect Oriented Programming Approach 2.1 Crosscutting global concerns We say that two concerns crosscut if the methods related to those concerns intersect. In simple words, these concerns cut through the system in a such a manner that they have to be addressed and taken care of at multiple points within the system. Examples of such behavior include the following: Synchronization and concurrency Performance optimization Exception handling and event monitoring Coordination and interaction protocols Object views In additional, crosscutting concerns cannot be neatly separately from each other. Hence an OOP solution to handling crosscutting concerns results in code that is intertwined with the code handling the actual functionality for which the module is designed. This means that the module is no longer cohesive in nature as it is addressing more that one issue. A simple example of a crosscutting concern would be a requirement that states that throughout the system, whenever an exception is thrown, a log has to be entered into an error log. This is a typical requirement and is a representative of requirements that are usually observed and identified during requirement analysis. Hence, to meet this requirement the usual approach would be to enclose the code for each method into structured exception handling blocks that catches the exception and makes an entry into the log file. This would solve the problem and meet the requirement stated. However, if a little more thought is given to this solution it would be evident that we just compromised the cohesiveness of our classes and the modules. Apart from providing the base functionality for which the class/module was designed, it also performs the task of making entries into the error log. Also, the code to make the error log will be present at each and every point in the code where an exception is being caught thus leading to a permeation of duplicate code throughout the system leading to lesser maintainability. Just to get a feel of the intensity of this problem try to think what would happen if the requirement suddenly changed and the code needs to be modified such that after making an error log, an needs to be sent to the administrator of the system with detailed information about the error that occurred and the exception that was thrown. In this case the code would need to be modified at all the points where the exception is being caught which would lead to a change being made in each of the hundreds of classes within the system! Consider a scenario where a new developer joins the team and forgets to write code in his exception handlers to make the error log. This kind of a scenario could lead to inconsistencies in the system. Hence, the inability of OOP in handling these crosscutting concerns pose a severe threat to the long term maintainability of the system. 2.2 AOP solution for global concerns Aspect-oriented programming (AOP) is a new paradigm that focuses on the issue of handling University of Houston Page 5 of 33

6 crosscutting global concerns. It proposes a solution by encapsulating the crosscutting concerns into single units called aspects. An aspect is a modular unit of crosscutting implementation and is designed to encapsulate state and behavior that affect multiple classes into reusable modules. Along the lines of AOP principles, the crosscutting concerns are identified and isolated from the localized concerns earlier during the requirements analysis phase. Thus, features of the system such as error-logging etc. are separated from functional requirements such as parsing, IO etc. that are local in nature. The functionality to handle these crosscutting concerns is then encapsulated into Aspects. The rest of the functional requirements can be then designed and addressed using a conventional technique. Afterwards, the aspecting code is combined with the aspected code to form a final executable with the help of an Aspect Weaver. Figure 3: Conventional compilation model [2] Figure 4: AOP approach to aspect weaving [2] Figure 3 depicts the conventional model where the various classes are cohesively designed to encapsulate individual functionality and are coded separately. The compiler then compiles the classes and builds a single executable from the class model. Figure 4 depicts the use of Aspect Oriented programming to solve a problem. In this case the system comprises of a system of classes that handle the localized functional concerns and a system of aspects that handle the global concerns. The aspect weaving is done as a pre-compilation process where the aspects and the classes and merged together to form a representation of the code that comprises of the appropriate aspecting code inserted at the appropriate points in the code where ever the global crosscutting concerns have to be addresses. This is then compiled to get the final executable. 2.3 What does AOP achieve The entire process of identification and isolation of crosscutting concerns is a time consuming job which requires a lot of experience to master and perfect. The process of designing aspects to address these concerns involves the use of a new paradigm and requires a need to step away from the conventional way of approaching the problem thus requiring a lot of time and effort. Then what is it that AOP achieves for us that OOP can not? University of Houston Page 6 of 33

7 The following are the benefits that accrue from the use of AOP to handle crosscutting concerns: 1. Modular Development: Aspects are independent s/w entities just like classes. They are designed to encapsulate behavior and functionality required to address global concerns and can also be designed to hold some state information. Since they are individual s/w units they have their own identity and can be developed, managed and treated separately from the rest of the system and can be built in a modular fashion. 2. Centralization of Aspecting code: The code that addresses the issues related to the global concern is centralized and neatly encapsulated within an aspect instead of being permeated throughout the system. Hence, the code is not duplicated thus making the system more consistent and maintainable. Any change to a crosscutting concern requirement can be easily handled since the change can be easily made at a single point within the code with minimal rippling effect. This also allows the addition or removal of aspecting functionality and gives a better control oven the functionality of the system. 3. Non-Intrusive approach to handling global cross-cutting concerns: AOP presents a perfectly non-intrusive approach towards handing crosscutting concerns. The code that is to be aspected is completely isolated and independent of the aspecting code before compilation. In the example discussed in section 2.1, if an AOP approach was taken then there would be a single aspect that would take care of the error-handling. Hence, there is no modification that is to be made to the existing code. Consider the situation where you want to perform this kind of error logging in a legacy system with a huge code base. AOP provides a mechanism by which you can non-intrusively introduce this kind of functionality into the system with little or no change to the existing code base by building an aspect hierarchy providing this functionality. By non-intrusiveness my focus is towards the fact that functionality to address crosscutting concerns can be added, modified or deleted without changing the current code base. This feature of AOP also enhances the extensibility of the system from a crosscutting concern perspective. 4. Increases cohesiveness of modules: Since aspects take care of the crosscutting concerns, the various classes and modules of the system remain independent of these concerns. Hence the modules are designed and developed to provide and cater to a single functionality leading to an increase in the cohesiveness of the modules and the system as a whole. 5. Logical separation of aspect code: AOP leads to a logical isolation and separation of the code to handle global concerns in the form of aspects from the rest of the system. This aid in an easy visualization of the system as a whole and in the identification of local and global functionality of the system. The logical separation is at the code level only since the final executable that is created after the AOP compilation contains the aspecting code intertwined with the regular code in the binary. But at the code level there is a crisp and distinct boundary between the aspects and the rest of the code. University of Houston Page 7 of 33

8 2.4 AOP and OOP: friends or foes Aspect Oriented Programming Object Oriented Programing Structured Programming Figure 3: Layering and dependence of programming paradigms A possible question that comes to mind is: Is AOP the next step after OOP? Will AOP replace OOP? OOP evolved due to the fact that Structured Programming could not address certain critical issues such as centralization and encapsulation of state and behavior. OOP proposed various mechanisms such as Inheritance and Polymorphism to deal with s/w complexity by modular development of systems through the realization of objects and classes. OOP however, did not discard the ideas of structures programming but actually formed a layer over it. In a similar fashion, AOP does not neglect or discard existing technologies and paradigms such as OOP but forms a layer over it. An aspect is nothing but a specialized class that handles the issue of global concerns. The OOP approach is to find commonality between classes and move it up the class hierarchy whereas AOP aims at identifying scattered concerns as crosscutting concerns and ejecting them horizontally from the object structure in the form of aspects. It layers over OOP and provides an efficient mechanism beyond the boundaries of methods and Inheritance to localize the functionality to address global concerns in the form of aspects that can be reused. Thus, the aim of AOP is not to replace OOP but to layer over OOP and provide additional capabilities to handle certain issues that the OOP paradigm is not capable of handling. University of Houston Page 8 of 33

9 3. Introduction to AspectJ 3.1 AOP insertion through AspectJ AspectJ is a general purpose aspect oriented extension for Java. The motivation that led to the creation of AspectJ was to provide an extension to Java that could provide AOP support through the use of a specialized Aspect description language (ADL). AspectJ is a freely available implementation which can be downloaded and provides a command line interface for AOP support as well as IDE support for tools like Eclipse and JBuilder. The following diagram shows how the process of aspect oriented compilation takes place. The aspects addressing the various crosscutting concerns are expressed through the use of a designed specialized syntax in an ADL 3 understood by AspectJ. These aspects along with the regular Java classes are fed as input to the AspectJ compiler which compiles the aspects and the classes as well as performs the aspect code intertwining. The result is a set of.class 4 binary Figure 4: Graphical representation of Aspect-Weaving through Aspect files which contain the regular code as well as the aspect code in an executable compatible with any Java Virtual Machine (JVM). 3.2 The Join-Point model Any AOP language support comprises of three important parts: a join-point model, means of identifying join-points and expressing the aspects associated with these join-points and a means of affecting the implementation at the join-points. Hence understanding the concept of a join-point is extremely crucial to grasp the fundamentals of AOP. 3 Aspect Description Language 4.class files are the complied files that are created when the java compiler is used to compile java code University of Houston Page 9 of 33

10 A join point is a well-defined point in the execution flow of a program. AspectJ has several kinds of well-defined join points: Method/constructor call join-points Method/constructor execution join-points Field get and set join-points Exception handler execution join-points Static and dynamic initialization join-points Join point does mot refer to a point within the physical code but a point within the execution flow of a program. For example, call to a method is an example of a join-point. Suppose we are interested in calls to a method named foo() of a class named xyz from anywhere in the application then this means that any point in the execution flow of the running program, where a call to this method, is made is a potential join-point for us. Hence, the entire course of execution of a program can be visualized as a collection of joinpoints such as method-calls, construction-calls etc. The processing at a join-point can be crisply divided into three parts: execution of the code until the join-point is reached, execution of the join-point itself (e.g. method that is called) and the execution of the code after the join-point. This view of the execution flow allows the identification of a join-point as a logical piece of executable that is surrounded by a certain context. For example, if the join-point is a call to a method then legal candidates for the context of the join-point would be the arguments being passed to the join-point, the return value from the method etc. Hence each and every join-point within the flow of execution has the following characteristics: 1. A valid point of entry 2. Context information for the join-point 3. A valid point of exit for the join-point 3.3 Important AOP Definitions 1. Pointcut A pointcut is used to select a small subset of join points out of the entire set of join-points associated with a particular executable context on the basis of well-defined filtering criteria. As defined in the previous section, any executable context could comprise of a large set of join-points where specific subsets of the join-points cater to a single crosscutting concern. For example, if we are interested to use AOP for error handling functionality like logging error information whenever an exception is thrown, then we would be interested in all the points in the execution flow where an exception is being caught. Each of these points actually represents a valid join-point. We are interested in all these join-points which are scattered over the entire span of execution flow at various different locations in the flow. These University of Houston Page 10 of 33

11 collectively form a subset of the entire collection of join-points within this particular execution context and we need a mechanism to express an interest in this particular subset of join-points. The concept of pointcut is designed specifically for this particular purpose. A simple example of a pointcut in AspectJ would be as follows: call (void GeometricFigures.DrawFigure (int)) The above statement is a pointcut that pick out each join-point that is a call to the method DrawFigure() on any object of class GeometricFugures which returns a void type and accepts an integer. call is an AspectJ keyword which is used to express calls to method, constructors etc. A pointcut can be built on other pointcuts with the use of operators such as and, or and not. Hence, the following pointcut definition is used to filter out all join-points that are calls to the DrawFigure() method of any object of the Circle or the Rectangle class. call (void Circle. DrawFigure (int)) call (void Rectangle. DrawFigure (int)) AspectJ supports the use of wildcard characters in the expression of pointcuts. For example, the following statement is used to select the join-points which are calls to a method of any object of a class named GeometricFigures with its name starting with the character sequence Draw, followed by zero or more characters and which accepts an int and returns a void. call (void GeometricFigures.Draw*(int)) Similarly, the following pointcut selects all join-points which represent calls to any method of an object of the class GeometricFigures. call (void GeometricFigures. *(int)) Sometimes there is a need to filter out join-points which are method calls but the actual sequence and type of the arguments which are being accepted by the method is not important. A typical example would be a case where we want to keep a count of the number of times any method of a class is being invoked at runtime. In this case we can use the wildcard character... call (void GeometricFigures. *(..)) The above statement is used to select the join-points which are calls to any method of any object of a class named GeometricFigures that accepts any number, sequence and type of arguments and returns a void. In the same lines the following statement is used to select the join-points which are calls to any method of any object of a class named GeometricFigures that accepts any number, sequence and type of arguments where the last argument is of type int and returns a void. University of Houston Page 11 of 33

12 call (void GeometricFigures. *(.., int)) 2. Advice An advice in AspectJ is used to define additional code that should be executed at a join-point. We have identified the join-points that we are interested in and created selection criteria to filter out these join-points as they are discovered during the flow of execution via pointcuts. However, in order to implement crosscutting behavior there should be a mechanism that would aid in specifying that a particular piece of code that has to be executed at a pointcut. This is expressed through the use of advice. An advice is nothing but a mechanism used to connect a pointcut to a body of code that needs to be executed at that pointcut. AspectJ has the following advices: 1. before advice: In this case the advice code executes when a join point is reached but before the computation proceeds. For example consider the following advice declaration: before (): call (void GeometricFigures.DrawFigure (int)) System.out.println( About to draw ); The above piece of code will be executed just after the call to the method is made and just before the method starts executing. 2. after advice: In this case the advice code executes just after the method body has run and just before control is returned to the caller. Java programs can leave a method call joinpoint 'normally' or by throwing an exception. To take care of these scenarios there are three kinds of after advice: after returning, after throwing, and plain after which runs after returning or throwing, like Java's finally. For example the following code will be executed after() returning: call (void GeometricFigures.DrawFigure (int)) System.out.println( Just drew successfully ); on a successful return from the method just before the control is returned to the caller. 3. around advice: In this case the advice code executes instead of the actual join-point when the join point is reached and conditions specified in the advice are satisfied. For example, in the following case the advice would be executed instead of the actual joinpoint, i.e. the entire join-point execution will be completely skipped. void around(): call (void GeometricFigures.DrawFigure (int)) System.out.println( Executed instead of Draw ); University of Houston Page 12 of 33

13 The original action associated with the join-point can be invoked through the special proceed keyword. void around(): call (void GeometricFigures.DrawFigure (int)) System.out.println( Executed before proceeding to Draw ); Proceed(); System.out.println( Executed after proceeding to Draw ); The above would be extremely useful in the conditional execution of the method depending upon some functions such as the value of a particular parameter being passes being in a certain range or checking the security context of the caller and denying execution of the method if the security criteria is not met. 3. Introduction or inter-type declarations An introduction in AspectJ provides a mechanism to introduce new members into an existent class definition or change the inheritance relationships between classes. The difference between introduction and advice is that the introductions take place at compile time and directly affect the structure of a class or the inheritance hierarchy of a system. The use of introduction becomes clear if we want to handle concerns such as adding a timestamp field within the classes of the application that we are building. The OOP solution would be to introduce fields into the class diagrams for this particular purpose. However if AOP is used then this would be possible with the help of introduction such that the field to be introduced is expressed in the form of an aspect and the actual introduction is made only at compile time thus providing a clear separation of these crosscutting concerns from the rest the code. To make alterations to the introductions we need to make changes only to the aspect, thus localizing the changes. 3.4 Exposing context at a join-point with pointcuts Apart from providing a mechanism to filter out the join-points, pointcuts also provide a method to expose the execution context at the join-point. I had discussed the execution context associated with a join-point earlier by taking the example of a method call join-point. The context exposed by a pointcut can be passed on to the advice method body in the form of parameters and arguments for usage. These can then be accessed and manipulated as regular variable within the body of the advice. The concept of exposing the context at a join-point will become clear with the following example. Consider a case where we are interested in trapping calls to the following: void GeometricFigures.DrawFigure (int) University of Houston Page 13 of 33

14 However there is an additional condition that we want to allow the call to the above method to proceed only if the value of the int variable being passed to it is greater than zero. The AOP solution to this problem would be to design a pointcut to filter out the required joinpoints and then access the variable being passed to the method. This would be possible by using the call keyword and an around advice since the around advice in this case would be executed just after the call is made to the method. At this point there is some execution context associated with the join-point which also includes the integer type argument being passed to the method. Hence in the advice body we need to access the argument somehow such that we can perform the test and depending upon the results either allow or disallow the call to proceed. The following piece of code does exactly what we have just discussed: around (GeometricFigures figure, int x): call (void GeometricFigures.DrawFigure (int)) && target(figure) &&args(x) if(x>0) System.out.println( Executed before proceeding to Draw ); Proceed(); System.out.println( Executed after proceeding to Draw ); else System.out.println( Condition not met ); System.out.println( Call to Draw aborted ); There are a couple of new concepts introduced in the above code that are extremely interesting. The most interesting part is the way the filtering of join-points is being done in order to expose the context. The expressed pointcut selects those join-points that are calls to the DrawFigure() method on objects of type GeometricFigures that accepts an int. It then exposed the context associated with these join-points through the use of the following statement: && target(figure) && args(x) target is a keyword which is used to express that when the above method is called then the object on which the method is being called should be exposed and the name of this object would be figure. This name is a temporary name used to associate the exposed object with the corresponding parameter being passed to the advice. The target, if exposed at the execution context is always the first parameter passed to the advice. The args keyword is University of Houston Page 14 of 33

15 used to convey that the first argument passed to the method should be exposed and published under the name x. The advice has a list of parameter which contains the Target type as the first parameter, if it is being exposed by the pointcut, followed by a list of all the types being exposed. The names of the arguments to the advice should match the names being published by the pointcut. In case there is no need to expose the target then we could simply achieve the required functionality through the following piece of code: before (int x): call (void GeometricFigures.DrawFigure (int)) && args(x) if(x>0) System.out.println( Executed before proceeding to Draw ); Proceed(); System.out.println( Executed after proceeding to Draw ); else System.out.println( Condition not met ); System.out.println( Call to Draw aborted ); In the above case, the target object is still a part of the execution context associated with the filtered join-point but it is not exposed and cannot be accessed in the advice. But we are still exposing the int type being passed and hence the argument list of the advice has a single argument of int type with the published name which can be accessed in the method body. 3.5 Named Pointcuts It is possible to provide a name for a pointcut to identify it. The advice can then be linked to the pointcut using the published name of the pointcut. The advantage of this approach is that it allows the programmer to associate a name to the pointcut and then link multiple advice blocks with the same pointcut. In the absence of this, the same pointcut would have to be expressed multiple times, once for each pointcut. The following example assigns a name to the pointcut and then associated two advice with it. pointcut drawing(int x): call (void GeometricFigures.DrawFigure (int)) && args(x) before(int x): drawing (x) University of Houston Page 15 of 33

16 System.out.println( Before Draw ); after(int x): drawing (x) System.out.println( After Draw ); Firstly, a unique name is given to the filtering criteria. Next step is to place name of the pointcut with the advice to link the filtering criteria with the advice. The arguments being passed are present along with the pointcut name declaration as well as the advice declaration. 3.6 call versus execution There are two interesting and distinct join-points associated with a method or constructor call. The call keyword is provided in AspectJ to refer to the join-point encountered just after a call is made to a method. In this case the enclosing code and the execution context is that of the calling method. Hence we use the call keyword in a pointcut declaration to filter out the join-points associated with a particular signature call. However, if we are interested in filtering out the join-points that occur just after control is passed to the called method and just before the first instruction is execute, we would use the keyword execution. In this case the enclosing code and the execution context is that of the called method. To highlight the difference between the two consider the following two pointcut declarations: pointcut drawing(int x) : call (void GeometricFigures.DrawFigure (int)) && withincode(void GeometricFigures.DrawFigure (..)) pointcut drawing(int x) : execution(void GeometricFigures.DrawFigure (int)) && withincode(void GeometricFigures.DrawFigure (..)) i ii There is a new keyword used in the above piece of code that is extremely interesting. The new keyword withincode is used to add additional restrictions to the filtering criteria by mentioning the code that should be executing when the join-point is reached. Hence it is possible to express an interest in a particular join-point only when the enclosing code is from a particular executing entity. In case of the first statement the pointcut filters out those join-points that are calls to the mentioned method and the enclosing code is again within the same method. This will effectively trap all recursive call to GeometricFigures.DrawFigure (..). The second one however filters out those join-points that are executions of the method and the enclosing code is the same method. Now a point to be noted is that at an execution join-point, the method is already being executed and hence the enclosing context is of the same method. Hence it is similar to saying: pointcut drawing(int x) : execution(void GeometricFigures.DrawFigure (int)) University of Houston Page 16 of 33

17 The keyword within can be used to express that the enclosing executing code should be within a particular class. This will include all the methods of the class including the constructors. Both the keywords can be used to further limit the join-points that are selected for consideration. The following example is used to trap the pointcuts which are call to the DrawFigure() method on any object of class GeometricFigures residing in the namespace Geometry. However there is an additional constraint in the declaration which says that that the pointcut should be encountered within the scope of the same class. Hence this would trap calls to the method from the collection of method within the class Geometry.GeometricFigures which includes the constructor as well as the Draw() method itself. This will exclude calls to the method from anywhere else in the application. pointcut drawing(int x) : call (void Geometry.GeometricFigures.DrawFigure (int)) && within(geometry.geometricfigures) 3.7 thisjoinpoint keyword What if you want to refer to the join-point itself within an advice body? There is a special reference variable in AspectJ, thisjoinpoint, of type org.aspectj.lang.joinpoint designed for this purpose. This keyword can be used to access the object that contains reflective information about the current join point for the advice to use. The thisjoinpoint variable can only be used in the context of advice, just like this can only be used in the context of nonstatic methods. A simple use of this would be to access the arguments associated with a joinpoint within the advice body as follows: thisjoinpoint.getargs() In addition, it holds an object consisting of all the static information about the join point such as corresponding line number and static signature: thisjoinpoint.getstaticpart() If you only need the static information about the join point, you may access the static part of the join point directly with the special variable thisjoinpointstaticpart. Using thisjoinpointstaticpart will avoid the run-time creation of the join point object that may be necessary when using thisjoinpoint directly. One more reflective variable is available: thisenclosingjoinpointstaticpart. This, like thisjoinpointstaticpart, only holds the static part of a join point, but it is not the current but the enclosing join point. So, for example, it is possible to print out the calling source location (if available) with the following declaration: before (): call (void GeometricFigures.DrawFigure (int)) System.out.println( University of Houston Page 17 of 33

18 thisenclosingjoinpointstaticpart. getsourcelocation(); 3.8 Wrapping it all in an aspect Aspects are used to wrap up and encapsulate pointcuts, advice, and introductions into a modular unit of crosscutting implementation. It is defined very much like a class, and can have methods, and fields in addition to the crosscutting members. AspectJ provides a new keyword aspect to declare an aspect. Because only aspects may include these crosscutting members, the declaration of these effects is localized. The following example wraps up all the code that we have written so far into an aspect by the name FigureDrawingTracker : aspect FigureDrawingTracker pointcut drawing(int x): call (void GeometricFigures.DrawFigure (int)) && args(x) before(int x): drawing (x) if(x>0) System.out.println( Executed before proceeding to Draw ); Proceed(); System.out.println( Executed after proceeding to Draw ); else System.out.println( Condition not met ); System.out.println( Call to Draw aborted ); System.out.println( thisenclosingjoinpointstaticpart. getsourcelocation(); after(int x): drawing (x) System.out.println( After Draw ); University of Houston Page 18 of 33

19 Like classes, aspects may be instantiated, but AspectJ controls how that instantiation happens and hence Java's new form cannot be used to build new aspect instances. By default, each aspect is a singleton and only one aspect instance is created. Hence the aspect class can have static fields that can be used to hold state information between the various advice bodies associated with a pointcut. University of Houston Page 19 of 33

20 4. Case study: Development Aspects We have discussed the various advantages of AOP over OOP in handling crosscutting concerns, defined the various concepts like join-points and pointcuts, dissected and studied the anatomy of an aspect and the syntax provided by AspectJ. Let us put it all together with the help of a couple of sample examples. The following problems are representatives of a number of similar problems encountered in day-to-day development activities which could be better solved using AOP. 4.1 Aspects to handle tracing concerns One of the most common activities associated during the development of production code is tracing. Developers spend a lot of time in writing code that traces common events during execution such as calls to methods or constructors, entering/leaving a method etc. This code is sometimes included in the actual source code with the intention of tracing and debugging during development. However, the approach taken to perform these activities is to permeate the code with a number f scattered statements which do the tracing job from different points within the program. There is no way of centralizing this task. One possible OOP approach would be to encapsulate the code to do the tracing within a class and access it through an interface. However, this would still result in tracing code being inserted into the application at various points that gets the job done by invoking methods of a class. Hence, in the end we end up permeating the existing code with method calls to do the job! Also, once this code has been TwoDimensionalFigures - x: int - y: int + getx(): double + gety(): double + getarea(): double + tostring(): string Circle - radius: int + getradius(): double - side: int Square + getside(): double + getdiagonallength(): double Figure 5: Class diagram for the geometricfigures class library University of Houston Page 20 of 33

21 inserted in multiple places, apart from the issue of code duplication there is also the question of removing this code if it is not needed. In this case, the entire code base needs to be searched to locate the small pieces of scattered tracing code to be cleaned up. The point that I am trying to make is that an OOP approach would fail to provide complete control over the tracing code. Full control would include an ability to add, remove or alter the tracing code by centralizing it at a single location in a non-intrusive manner such that there would be no need to modify the existing code apart from the tracing code. An AOP solution to the above problem would provide all the capabilities that an OOP solution could not provide. An initial analysis of the above problem reveals one important feature of the problem at hand it is a crosscutting concern. Tracing is a valid example of a crosscutting concern since this concern cuts orthogonally across a number of classes and requires coding in a number of places to perform the same task. But the points at which we have to perform tracing such as method calls, event invocation etc. are all join-points in one form or the other. Hence we can use AOP to solve this problem if we go the following route: Identify individual groups of join-points of interest for tracing activities Design pointcuts to filter out these groups Associate advice with these pointcuts to perform the logging activities The following section shows the details of how to go about this implementation by taking the University of Houston Page 21 of 33

22 Figure 6: Snap-shot of code for class TwoDimensionalFigures Figure 7: Snap-shot of code for class Circle that extends class TwoDimensionalFigures Figure 8: Snap-shot of code for class Square that extends class TwoDimensionalFigures University of Houston Page 22 of 33

23 example of a class hierarchy of geometric figures. Figure [5] is a class diagram with an abstract class TwoDimensionalFigures in the geometricfigures namespace which is the base class for all geometric figures. It has the properties and behavior characteristic of all geometric figures including two abstract methods: getarea() and tostring(). Two concrete classes Circle and Square extend this class providing implementations for the abstract methods as well as some properties and methods characteristic of the concrete classes. This completes the sample test hierarchy. The sample application also includes a driver class that acts as the user of this class library and creates and uses object by invoking methods on them. Figure 9: Snap-shot of code for the driver class MainDriver Figures [6-9] are screen-shots displaying the code written for these four classes: In the main method two objects of Circle and Square are created using a pointer of base type University of Houston Page 23 of 33

24 Figure 10: Snap-shot of the console window displaying the output for the above program and then it is used to invoke methods on the respective objects. If the above code was executed as it is now then the output would be as in the snap-shot shown in figure 10. At this point we can start introducing aspects into the code to perform the tracing. The following snapshot is of an aspect named MethodCallTracer. This aspect has a named pointcut, trace, that filters out join-points that are calls to the tostring() method on any object that is of type geometricfugures.twodimensionalfigures. Note that since this is an abstract class, it cannot be instantiated. However, the classes that extend this class are fully substitutable in Figure 11: Snap-shot of MethodCallTracer aspect for tracing on method calls University of Houston Page 24 of 33

25 the place of the parent in a well-designed OOP system 5. Hence, calls to the derived or extended methods on object of the concrete classes would also be trapped by this pointcut. The aspect also has an anonymous aspect to trap calls to the getarea() method. It also contains the associated advices to perform the necessary tracing functions. To demonstrate that multiple aspects could be included in the same project, I have included the following aspect to trap calls to the getdiagonallength() of the Square class and the corresponding advice to perform tracing. Figure 12: Snap-shot of SquareClassLogger aspect Figure 13 is a screen-shot displaying the final output after the aspects are included into the project. Join-points that are calls to the methods inherited from the base class by the derived classes, invoked on objects of the derived classes are trapped by the corresponding pointcuts defined in the MethodCallTracer aspect. The pointcuts have associated before advice which is given a chance to perform the required tracing functions before the call is allowed to proceed. The advice body just prints tracing on the console for simplicity. However, advice body can be developed to perform advance tracing functions such as writing trace information to a trace file etc. Similarly the SquareClassLogger is designed to trap calls to a specific method of a concrete class and perform tracing activities by using the associated 5 A well des designed OOP solution would follow Liskov s substitutability Principle (LSP) which states that An object of a base class should be fully substitutable by an object of the base class without loss of functionality. University of Houston Page 25 of 33

26 advice. If two pointcuts end up selecting the same join-point based on the given filtering criteria then the order in which the associated advice bodies will be executed is undetermined and none of the logic used should be based on the sequence in which the method bodies execute. Figure 13: Snap-shot of the console window displaying the final output There are several advantages to this approach as compared to the OOP approach which can be summarized as follows: Since the tracing code is centralized and wrapped in an aspect, the modularity and cohesiveness of the other modules is preserved. Changes to the tracing code can be made easily by making changes to the aspects without changing any other code. Pointcuts could be generic or specific as depicted in the above example depending upon how specific is the filtering criteria. Tracing functionality can be easily added, modified or deleted in a non-intrusive manner giving complete control on tracing for the entire application. Pointcuts can be carefully designed to take care of join-points associated with discrete points in an inheritance hierarchy. 4.2 Aspects to handle logging & profiling The next sample problem, to further emphasize the ability of AOP, is of another common crosscutting concern: Logging and Profiling. Logging activities such as error logging is an important requirement in many software applications. Again, this particular concern is global in nature and an appropriate target for an AOP solution. The following application includes a calculator class that provides basic calculating functions. There are two static methods in this class, PositiveNumberAdder() & PositiveNumberSubtractor() which are used to perform check on the input arguments and if they are found to be negative then a custom exception of type NegativeNumberException is thrown. There is a class CalculationPerformer that uses the above class to perform some computations as shown. Figure [16] is a snap-shot of the output if the code was run as it is. The second method call in the function causes an exception to be thrown which is caught by the exception handler and printed on the console. University of Houston Page 26 of 33

27 Figure 14: Snap-shot of the Calculator class in the mathpackage namespace Figure 15: Snap-shot of the console output To add the error logging functionality an aspect is introduced into the solution: ErrorLogger. This aspect contains an anonymous pointcut definition to trap all join-points that are calls to any method on any type of object. This is achieved with the use of the wildcards in the following expression: call (* *(..)) The above expression would trap calls to any method of any class which accepts zero or more arguments of any type independent of the return type which could also be a void type. University of Houston Page 27 of 33

Aspect-Oriented Programming

Aspect-Oriented Programming Aspect-Oriented Programming An Introduction to Aspect-Oriented Programming and AspectJ Niklas Påhlsson Department of Technology University of Kalmar S 391 82 Kalmar SWEDEN Topic Report for Software Engineering

More information

Progress Report Aspect Oriented Programming meets Design Patterns. Academic Programme MSc in Advanced Computer Science. Guillermo Antonio Toro Bayona

Progress Report Aspect Oriented Programming meets Design Patterns. Academic Programme MSc in Advanced Computer Science. Guillermo Antonio Toro Bayona Progress Report Aspect Oriented Programming meets Design Patterns Academic Programme MSc in Advanced Computer Science Guillermo Antonio Toro Bayona Supervisor Dr. John Sargeant The University of Manchester

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

Chapter 5 Aspect Oriented Programming

Chapter 5 Aspect Oriented Programming 2I1AC3 : Génie logiciel et Patrons de conception Chapter 5 Aspect Oriented Programming J'ai toujours rêvé d'un ordinateur qui soit aussi facile à utiliser qu'un téléphone. Mon rêve s'est réalisé. Je ne

More information

Aspect Oriented Programming. with. Spring

Aspect Oriented Programming. with. Spring Aspect Oriented Programming with Spring Problem area How to modularize concerns that span multiple classes and layers? Examples of cross-cutting concerns: Transaction management Logging Profiling Security

More information

Integration of Application Business Logic and Business Rules with DSL and AOP

Integration of Application Business Logic and Business Rules with DSL and AOP Integration of Application Business Logic and Business Rules with DSL and AOP Bogumiła Hnatkowska and Krzysztof Kasprzyk Wroclaw University of Technology, Wyb. Wyspianskiego 27 50-370 Wroclaw, Poland Bogumila.Hnatkowska@pwr.wroc.pl

More information

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces

Decomposition into Parts. Software Engineering, Lecture 4. Data and Function Cohesion. Allocation of Functions and Data. Component Interfaces Software Engineering, Lecture 4 Decomposition into suitable parts Cross cutting concerns Design patterns I will also give an example scenario that you are supposed to analyse and make synthesis from The

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship. CSCI 253 Object Oriented Design: Java Review OOP George Blankenship George Blankenship 1 Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation Abstract Data Type (ADT) Implementation

More information

Integration of Application Business Logic and Business Rules with DSL and AOP

Integration of Application Business Logic and Business Rules with DSL and AOP e-informatica Software Engineering Journal, Volume 4, Issue, 200 Integration of Application Business Logic and Business Rules with DSL and AOP Bogumiła Hnatkowska, Krzysztof Kasprzyk Faculty of Computer

More information

Fundamentals of Java Programming

Fundamentals of Java Programming Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors

More information

Remote Pointcut - A Language Construct for Distributed AOP

Remote Pointcut - A Language Construct for Distributed AOP Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori (IBM) 1 Pointcut-advice model Joinpoints Program execution is modeled

More information

Coordinated Visualization of Aspect-Oriented Programs

Coordinated Visualization of Aspect-Oriented Programs Coordinated Visualization of Aspect-Oriented Programs Álvaro F. d Arce 1, Rogério E. Garcia 1, Ronaldo C. M. Correia 1 1 Faculdade de Ciências e Tecnologia Universidade Estadual Paulista Júlio de Mesquita

More information

Chapter 1 Fundamentals of Java Programming

Chapter 1 Fundamentals of Java Programming Chapter 1 Fundamentals of Java Programming Computers and Computer Programming Writing and Executing a Java Program Elements of a Java Program Features of Java Accessing the Classes and Class Members The

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Generating Aspect Code from UML Models

Generating Aspect Code from UML Models Generating Aspect Code from UML Models Iris Groher Siemens AG, CT SE 2 Otto-Hahn-Ring 6 81739 Munich, Germany Iris.Groher@fh-hagenberg.at Stefan Schulze Siemens AG, CT SE 2 Otto-Hahn-Ring 6 81739 Munich,

More information

Unification of AOP and FOP in Model Driven Development

Unification of AOP and FOP in Model Driven Development Chapter 5 Unification of AOP and FOP in Model Driven Development I n this chapter, AOP and FOP have been explored to analyze the similar and different characteristics. The main objective is to justify

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations

More information

How To Develop Software

How To Develop Software Software Engineering Prof. N.L. Sarda Computer Science & Engineering Indian Institute of Technology, Bombay Lecture-4 Overview of Phases (Part - II) We studied the problem definition phase, with which

More information

Computing Concepts with Java Essentials

Computing Concepts with Java Essentials 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Fourth generation techniques (4GT)

Fourth generation techniques (4GT) Fourth generation techniques (4GT) The term fourth generation techniques (4GT) encompasses a broad array of software tools that have one thing in common. Each enables the software engineer to specify some

More information

The Service Revolution software engineering without programming languages

The Service Revolution software engineering without programming languages The Service Revolution software engineering without programming languages Gustavo Alonso Institute for Pervasive Computing Department of Computer Science Swiss Federal Institute of Technology (ETH Zurich)

More information

Managing Variability in Software Architectures 1 Felix Bachmann*

Managing Variability in Software Architectures 1 Felix Bachmann* Managing Variability in Software Architectures Felix Bachmann* Carnegie Bosch Institute Carnegie Mellon University Pittsburgh, Pa 523, USA fb@sei.cmu.edu Len Bass Software Engineering Institute Carnegie

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

Instrumentation Software Profiling

Instrumentation Software Profiling Instrumentation Software Profiling Software Profiling Instrumentation of a program so that data related to runtime performance (e.g execution time, memory usage) is gathered for one or more pieces of the

More information

Software Engineering Techniques

Software Engineering Techniques Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary

More information

New Generation of Software Development

New Generation of Software Development New Generation of Software Development Terry Hon University of British Columbia 201-2366 Main Mall Vancouver B.C. V6T 1Z4 tyehon@cs.ubc.ca ABSTRACT In this paper, I present a picture of what software development

More information

Realizing Enterprise Integration Patterns in WebSphere

Realizing Enterprise Integration Patterns in WebSphere Universität Stuttgart Fakultät Informatik, Elektrotechnik und Informationstechnik Realizing Enterprise Integration Patterns in WebSphere Thorsten Scheibler, Frank Leymann Report 2005/09 October 20, 2005

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science updated 03/08/2012 Unit 1: JKarel 8 weeks http://www.fcps.edu/is/pos/documents/hs/compsci.htm

More information

A standards-based approach to application integration

A standards-based approach to application integration A standards-based approach to application integration An introduction to IBM s WebSphere ESB product Jim MacNair Senior Consulting IT Specialist Macnair@us.ibm.com Copyright IBM Corporation 2005. All rights

More information

KWIC Implemented with Pipe Filter Architectural Style

KWIC Implemented with Pipe Filter Architectural Style KWIC Implemented with Pipe Filter Architectural Style KWIC Implemented with Pipe Filter Architectural Style... 2 1 Pipe Filter Systems in General... 2 2 Architecture... 3 2.1 Pipes in KWIC system... 3

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

Object Oriented Design

Object Oriented Design Object Oriented Design Kenneth M. Anderson Lecture 20 CSCI 5828: Foundations of Software Engineering OO Design 1 Object-Oriented Design Traditional procedural systems separate data and procedures, and

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: 1.800.529.0165 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming

More information

Foundation of Aspect Oriented Business Process Management

Foundation of Aspect Oriented Business Process Management Foundation of Aspect Oriented Business Process Management Amin Jalali Department of Computer and Systems Sciences Degree project 30 HE credits Degree subject: computer and Systems Sciences Degree project

More information

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY 2.1 Introduction In this chapter, I am going to introduce Database Management Systems (DBMS) and the Structured Query Language (SQL), its syntax and usage.

More information

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program

More information

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont. Objectives To describe the services an operating system provides to users, processes, and other systems To discuss the various ways of structuring an operating system Chapter 2: Operating-System Structures

More information

Enhancing Effectiveness of WATIR through Keyword Driven Framework

Enhancing Effectiveness of WATIR through Keyword Driven Framework Enhancing Effectiveness of WATIR through Keyword Driven Framework AVASOFT Technologies PVT Ltd, Chennai 600042 1 P a g e Table of Contents 1.0 Abstract..3 2.0 Technology Overview... 4 2.1 Ruby... 4 2.2

More information

Gadget: A Tool for Extracting the Dynamic Structure of Java Programs

Gadget: A Tool for Extracting the Dynamic Structure of Java Programs Gadget: A Tool for Extracting the Dynamic Structure of Java Programs Juan Gargiulo and Spiros Mancoridis Department of Mathematics & Computer Science Drexel University Philadelphia, PA, USA e-mail: gjgargiu,smancori

More information

I. INTRODUCTION. International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 2, Mar-Apr 2015

I. INTRODUCTION. International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 2, Mar-Apr 2015 RESEARCH ARTICLE An Exception Monitoring Using Java Jyoti Kumari, Sanjula Singh, Ankur Saxena Amity University Sector 125 Noida Uttar Pradesh India OPEN ACCESS ABSTRACT Many programmers do not check for

More information

Compose*: Language-Independent Aspects for.net

Compose*: Language-Independent Aspects for.net Compose*: Language-Independent Aspects for.net Lodewijk M.J. Bergmans [lbergmans@acm.org] TRESE group,, The Netherlands [] 1 Intro: Aspect-Orientation Aspect-Oriented Software Development (AOSD): Improve

More information

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing

More information

How to test and debug an ASP.NET application

How to test and debug an ASP.NET application Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult

More information

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming Java has become enormously popular. Java s rapid rise and wide acceptance can be traced to its design

More information

Programming and Software Development CTAG Alignments

Programming and Software Development CTAG Alignments Programming and Software Development CTAG Alignments This document contains information about four Career-Technical Articulation Numbers (CTANs) for Programming and Software Development Career-Technical

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the

More information

UML for the C programming language.

UML for the C programming language. Functional-based modeling White paper June 2009 UML for the C programming language. Bruce Powel Douglass, PhD, IBM Page 2 Contents 2 Executive summary 3 FunctionalC UML profile 4 Functional development

More information

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration Developer Web Age Solutions Inc. USA: 1-877-517-6540 Canada: 1-866-206-4644 Web: http://www.webagesolutions.com Chapter 6 - Introduction

More information

OO Design Quality Metrics

OO Design Quality Metrics OO Design Quality Metrics An Analysis of Dependencies By Robert Martin October 28,1994 2080 Cranbrook Road Green Oaks, IL 60048 Phone: 708.918.1004 Fax: 708.918.1023 Email: rmartin@oma.com Abstract This

More information

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

More information

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Directions: In mobile Applications the Control Model View model works to divide the work within an application.

More information

SECTION 5: Finalizing Your Workbook

SECTION 5: Finalizing Your Workbook SECTION 5: Finalizing Your Workbook In this section you will learn how to: Protect a workbook Protect a sheet Protect Excel files Unlock cells Use the document inspector Use the compatibility checker Mark

More information

Chapter 4: Tools of Modern Systems Analysis

Chapter 4: Tools of Modern Systems Analysis Just Enough Structured Analysis Chapter 4: Tools of Modern Systems Analysis Nature has... some sort of arithmetical-geometrical coordinate system, because nature has all kinds of models. What we experience

More information

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0 The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Going Interactive: Combining Ad-Hoc and Regression Testing

Going Interactive: Combining Ad-Hoc and Regression Testing Going Interactive: Combining Ad-Hoc and Regression Testing Michael Kölling 1, Andrew Patterson 2 1 Mærsk Mc-Kinney Møller Institute, University of Southern Denmark, Denmark mik@mip.sdu.dk 2 Deakin University,

More information

Course Title: Software Development

Course Title: Software Development Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.

More information

Database Programming with PL/SQL: Learning Objectives

Database Programming with PL/SQL: Learning Objectives Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Improved Software Testing Using McCabe IQ Coverage Analysis

Improved Software Testing Using McCabe IQ Coverage Analysis White Paper Table of Contents Introduction...1 What is Coverage Analysis?...2 The McCabe IQ Approach to Coverage Analysis...3 The Importance of Coverage Analysis...4 Where Coverage Analysis Fits into your

More information

Enterprise AOP with Spring Applications IN ACTION SAMPLE CHAPTER. Ramnivas Laddad FOREWORD BY ROD JOHNSON MANNING

Enterprise AOP with Spring Applications IN ACTION SAMPLE CHAPTER. Ramnivas Laddad FOREWORD BY ROD JOHNSON MANNING Enterprise AOP with Spring Applications IN ACTION SAMPLE CHAPTER Ramnivas Laddad FOREWORD BY ROD JOHNSON MANNING AspectJ in Action Second Edition by Ramnivas Laddad Chapter 10 Copyright 2010 Manning Publications

More information

Combining Static and Dynamic Impact Analysis for Large-scale Enterprise Systems

Combining Static and Dynamic Impact Analysis for Large-scale Enterprise Systems Combining Static and Dynamic Impact Analysis for Large-scale Enterprise Systems The 15th International Conference on Product-Focused Software Process Improvement, Helsinki, Finland. Wen Chen, Alan Wassyng,

More information

Debugging Java Applications

Debugging Java Applications Debugging Java Applications Table of Contents Starting a Debugging Session...2 Debugger Windows...4 Attaching the Debugger to a Running Application...5 Starting the Debugger Outside of the Project's Main

More information

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error

More information

C Compiler Targeting the Java Virtual Machine

C Compiler Targeting the Java Virtual Machine C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the

More information

Aspect Refactoring Verifier

Aspect Refactoring Verifier Aspect Refactoring Verifier Charles Zhang and Julie Waterhouse Hans-Arno Jacobsen Centers for Advanced Studies Department of Electrical and IBM Toronto Lab Computer Engineering juliew@ca.ibm.com and Department

More information

CHAPTER 10: WEB SERVICES

CHAPTER 10: WEB SERVICES Chapter 10: Web Services CHAPTER 10: WEB SERVICES Objectives Introduction The objectives are: Provide an overview on how Microsoft Dynamics NAV supports Web services. Discuss historical integration options,

More information

Oracle Service Bus Examples and Tutorials

Oracle Service Bus Examples and Tutorials March 2011 Contents 1 Oracle Service Bus Examples... 2 2 Introduction to the Oracle Service Bus Tutorials... 5 3 Getting Started with the Oracle Service Bus Tutorials... 12 4 Tutorial 1. Routing a Loan

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Object Instance Profiling

Object Instance Profiling Object Instance Profiling Lubomír Bulej 1,2, Lukáš Marek 1, Petr Tůma 1 Technical report No. 2009/7, November 2009 Version 1.0, November 2009 1 Distributed Systems Research Group, Department of Software

More information

XPoints: Extension Interfaces for Multilayered Applications

XPoints: Extension Interfaces for Multilayered Applications XPoints: Extension Interfaces for Multilayered Applications Mohamed Aly, Anis Charfi, Sebastian Erdweg, and Mira Mezini Applied Research, SAP AG firstname.lastname@sap.com Software Technology Group, TU

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

Component visualization methods for large legacy software in C/C++

Component visualization methods for large legacy software in C/C++ Annales Mathematicae et Informaticae 44 (2015) pp. 23 33 http://ami.ektf.hu Component visualization methods for large legacy software in C/C++ Máté Cserép a, Dániel Krupp b a Eötvös Loránd University mcserep@caesar.elte.hu

More information

Johannes Sametinger. C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria

Johannes Sametinger. C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria OBJECT-ORIENTED DOCUMENTATION C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria Abstract Object-oriented programming improves the reusability of software

More information

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT, 15.1200.40

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT, 15.1200.40 SOFTWARE DEVELOPMENT, 15.1200.40 STANDARD 1.0 APPLY PROBLEM-SOLVING AND CRITICAL THINKING SKILLS TO INFORMATION 1.1 Describe methods of establishing priorities 1.2 Prepare a plan of work and schedule information

More information

COMP 110 Prasun Dewan 1

COMP 110 Prasun Dewan 1 COMP 110 Prasun Dewan 1 12. Conditionals Real-life algorithms seldom do the same thing each time they are executed. For instance, our plan for studying this chapter may be to read it in the park, if it

More information

Object Oriented Software Design - I

Object Oriented Software Design - I Object Oriented Software Design - I Object Oriented Design Principles Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2011 G. Lipari (Scuola Superiore Sant Anna)

More information

Aspectual Mixin Layers

Aspectual Mixin Layers Aspectual Mixin Layers Sven Apel, Thomas Leich, and Gunter Saake Department of Computer Science University of Magdeburg, Germany email: {apel,leich,saake}@iti.cs.uni-magdeburg.de Abstract. Feature-Oriented

More information

Lab Experience 17. Programming Language Translation

Lab Experience 17. Programming Language Translation Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly

More information

Embedded Software Development with MPS

Embedded Software Development with MPS Embedded Software Development with MPS Markus Voelter independent/itemis The Limitations of C and Modeling Tools Embedded software is usually implemented in C. The language is relatively close to the hardware,

More information

MA-WA1920: Enterprise iphone and ipad Programming

MA-WA1920: Enterprise iphone and ipad Programming MA-WA1920: Enterprise iphone and ipad Programming Description This 5 day iphone training course teaches application development for the ios platform. It covers iphone, ipad and ipod Touch devices. This

More information

Getting Started with the Internet Communications Engine

Getting Started with the Internet Communications Engine Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2

More information

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution 16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

More information

Java Programming Language

Java Programming Language Lecture 1 Part II Java Programming Language Additional Features and Constructs Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Subclasses and

More information

Test Automation Framework

Test Automation Framework Test Automation Framework Rajesh Popli Manager (Quality), Nagarro Software Pvt. Ltd., Gurgaon, INDIA rajesh.popli@nagarro.com ABSTRACT A framework is a hierarchical directory that encapsulates shared resources,

More information

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

More information

Harmless Advice. Daniel S Dantas Princeton University. with David Walker

Harmless Advice. Daniel S Dantas Princeton University. with David Walker Harmless Advice Daniel S Dantas Princeton University with David Walker Aspect Oriented Programming Aspect Oriented Programming IBM - 2004 IBM reports positive results in aspect-oriented programming experiments

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1. Software Organization View to this point: CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

More information

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach TRAINING & REFERENCE murach's SQL Server 2012 for developers Bryan Syverson Joel Murach Mike Murach & Associates, Inc. 4340 N. Knoll Ave. Fresno, CA 93722 www.murach.com murachbooks@murach.com Expanded

More information

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

More information

Verifying Semantic of System Composition for an Aspect-Oriented Approach

Verifying Semantic of System Composition for an Aspect-Oriented Approach 2012 International Conference on System Engineering and Modeling (ICSEM 2012) IPCSIT vol. 34 (2012) (2012) IACSIT Press, Singapore Verifying Semantic of System Composition for an Aspect-Oriented Approach

More information

Chapter 13: Program Development and Programming Languages

Chapter 13: Program Development and Programming Languages 15 th Edition Understanding Computers Today and Tomorrow Comprehensive Chapter 13: Program Development and Programming Languages Deborah Morley Charles S. Parker Copyright 2015 Cengage Learning Learning

More information