Aspect-Oriented Programming

Aspect-Oriented Programming

Vladimir O. Safonov (St. Petersburg State University, Russia)
DOI: 10.4018/978-1-4666-5888-2.ch693
OnDemand PDF Download:
$30.00
List Price: $37.50

Chapter Preview

Top

Background

A concern in software development is an idea, consideration, or design of some functionality to be implemented in the target software application. Software concerns can be subdivided into common concerns and cross-cutting concerns. So the task of software development can be regarded as separating and implementing its concerns. A common concern is a concern whose implementation can be made using generalized procedures (procedures, macros, classes, or other traditional modular programming features) only. However, there also exist cross-cutting concerns whose implementation, due to their nature, should consist of a set of scattered code fragments penetrating the code of the target application. Typical example of a cross-cutting concern is a set of security checks (for some permission) that should be done in each of or in most of the target application’s software modules. If security checks are lacking in the initial version of the application they should be inserted, which is an error-prone task, uncomfortable and unsafe to do “by hand,” especially if the target application is large. With traditional programming style, fragments of implementations of cross-cutting concerns are tangled within the target application code, so it may be difficult to separate them from each other.

Aspect-oriented programming is intended to solve the task of implementing and handling cross-cutting concerns in modular way. Each cross-cutting concern is implemented by a special, novel kind of module, referred to as aspect – an implementation of a cross-cutting concern. The concept of aspect extends the original concept of software module introduced by Myers in the 1970s.The definition of an aspect, in our terms (Safonov, 2008), contains aspect actions – the code fragments to be activated in some selected points of the target application. The target application is updated using an aspect or set of aspects by their weaving – injecting aspect actions into the desirable join points of the target application, or enabling to activate aspect actions in those join points some other way at runtime. The join points of the target application where to activate the appropriate aspect actions are filtered on the basis of weaving rules – the rules to locate join points in target applications. Weaving rules are parts of aspect definition. Each weaving rule is associated with some aspect action. Typical example of a weaving rule and its associated aspect action is as follows: Before call of each method of the target application, insert a code to issue a message of the kind: “Hello M” where M is the method name. In more traditional terms (Kiczales et al., 1997), a pointcut is a set of conditions to filter out the join points. A pointcut may be not related to any concrete aspect, and different aspects can refer to the same pointcut. Advice is an aspect action to be executed at a selected join point. Any part of aspect definition specifying how to weave some advice can be regarded as a construct of the kind:

if Condition then Advice

where Condition is a condition to hold during execution of the target program for the Advice to be activated.

Key Terms in this Chapter

Aspect Action: Part of an aspect, the code fragment to be woven into the target application according to the appropriate weaving rule of the aspect.

Weaving: Method of applying an aspect to some target application by injecting the code of aspect actions into the join points of the target application selected using the weaving rules of the aspect, or of activating aspect actions in the target join points at runtime.

Cross-Cutting Concern: A concern that, due to its nature, should be implemented by a set of scattered code fragments in the target application (e.g., security checks).

Advice: The same as aspect action: part of an aspect, the code fragment to be woven into the target application according to the appropriate weaving rule of the aspect.

Aspect: An implementation of a cross-cutting concern.

Pointcut: A set of weaving rules to filter join points of a target application, typically not tied to some concrete aspect.

Join Point: A point in the target application code where to weave the code of an aspect’s action.

Weaving Rule: Part of an aspect, a rule to filter the join points in the target application, for the purpose of weaving the aspect into it.

Complete Chapter List

Search this Book:
Reset