| Aspect-Oriented Programming(AOP) is a programming paradigm that aims to increase modularity by allowing the separation of crosscutting concerns, especially in complex applications. In contrast with OOP, AOP is a way of modularizing crosscutting concerns. Crosscutting concern is a concern that affects several classes or modules. The modules for the crosscutting concerns are called aspects, aspects encapsulate behaviors that affect multiple classes into reusable modules.AspectJ is the most prevalent and studied in mainstream aspect languages. AspectJ introduces a new concept a pointcut is a construct designed to identify and select join points. Advice defines code to be executed when a join point is reached. It is, however, not easy to capture the proper join points. If an advice should not be executed, the relevant join points are inproper. For example, in an graphic operation program, there is a refreshing the screen method as one of the advices, this advice excuted at where both the proper and inproper join points were captured, so as to the screen refreshed a lot unnecessarily. Also it has effect not only on increasing the efficiency of the program running of aspect-oriented programming language but also reducing errors that may occur.In our approach we propose a novel mechanism called constraint-based pointcuts. A constraint-based pointcut matches join points which are restricted by a constraint. The constraint-based pointcut is given the constraint satisfied by the pointcut, pointcut capture join points satisfy the condition of constraint. To specify join point selections based on different constraints, we propose a constraint model so as to define several constraints for the concepts which are implemented by the base program entities.The constraint model provides an abstraction over the structure of the code implementation. In constraint model, the developer can define several constraints for the concepts which are implemented by the base program entities. The constraints could be the limit of numbers, constraint of properties, or restriction names and other constraints. The concepts are defined in the constraint model to describe constraint model correct classification, and they could be constructed in the source code.In our approach annotations can be consider as the entities express the concept constraint of the constraint model. In AspectJ, annotation can support matching join points based on the presence or absence of annotations. The classifications of source-code entities in the constraint model could be constructed using annotations in the source code.Control-flow based pointcut is a good way to implement the constraint in AspectJ. In this way, we do not need to extend any syntactic to the existing AOP language. Using !cflowbelow(pointcut) can specifies only the root join point. The cflowbelow(pointcut) means: every join point below the control flow of each join point which picked out by a pointcut, does not include itself.We evaluate our approach by using a case study of JHotDraw. It shows that our approach of Contraint-based Pointcut is valid on reducing advices repeated problem than traditional pointcut. Potential future work entails increase accuracy of capturing repeated join points by our Contraint-based pointcut. |