HOME

TheInfoList



OR:

In
aspect-oriented programming In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying ...
, a pointcut is a set of join points. Pointcut specifies where exactly to apply advice, which allows separation of concerns and helps in modularizing business logic. Pointcuts are often specified using class names or method names, in some cases using regular expressions that match class or method name. Different frameworks support different Pointcut expressions;
AspectJ AspectJ is an aspect-oriented programming (AOP) extension created at PARC for the Java programming language. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become a widely use ...
syntax is considered as de facto standard. Frameworks are available for various programming languages like
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
,
Perl Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
,
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
, and many more which support pointcut.


Background

Due to limitations in various programming languages, cross-cutting concern has not modularized. Cross-cutting concern refers to parts of software that logically belong to one module and affect the whole system: this could be security or logging, for example.
Aspect-oriented programming In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying ...
tries to solve these cross cutting concerns by allowing programmers to write modules called aspects, which contain pieces of code executed at particular point. The expressions required to select a particular point led to creation of Pointcut Expressions.


Execution

Whenever the program execution reaches one of the join points described in the pointcut, a piece of code associated with the pointcut (called advice) is executed. This allows a programmer to describe where and when additional code should be executed in addition to already-defined behavior. Pointcut permits the addition of aspects to existing software, as well as the design of software with a clear
separation of concerns In computer science, separation of concerns is a design principle for separating a computer program into distinct sections. Each section addresses a separate '' concern'', a set of information that affects the code of a computer program. A concern ...
, wherein the programmer
weaves Artificial hair integrations, more commonly known as hair extensions, hair weaves, and fake hair add length and fullness to human hair. Hair extensions are usually clipped, glued, or sewn on natural hair by incorporating additional human or syn ...
(merges) different aspects into a complete application.


Example

Suppose there is an application where we can modify records in a
database In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases spa ...
. Whenever users modify the database, we want to have a log of information regarding who is modifying the records. The traditional way to log is to call a log method just before modifying the database. With aspect-oriented programming, we can apply pointcut to the Modify Database method and have an advice that is called to log the required information.


Expressions

Following are some of the important pointcut expressions supported by
AspectJ AspectJ is an aspect-oriented programming (AOP) extension created at PARC for the Java programming language. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become a widely use ...
. These expressions can be combined using logical operators. execution(void User.setPassword(password)) This pointcut matches execution of the User.setPassword method. call(void User.getPassword()) When User.getPassword is called, this pointcut is matched. handler(ArrayIndexOutOfBounds) Pointcut will match when there is an ArrayIndexOutOfBounds exception this(UserType) Pointcut will match when the object currently executing is of UserType. target(UserType) Pointcut will match when the target object is of UserType. within(UserType) Pointcut will match when the code executing belongs to UserType.


Criticisms

Pointcut languages impact important software properties like
evolvability Evolvability is defined as the capacity of a system for adaptive evolution. Evolvability is the ability of a population of organisms to not merely generate genetic diversity, but to generate '' adaptive'' genetic diversity, and thereby evolve thr ...
and comprehensibility in a negative way. There might be a possibility where there is a need to perform
refactoring In computer programming and software design, code refactoring is the process of restructuring existing computer code—changing the '' factoring''—without changing its external behavior. Refactoring is intended to improve the design, structu ...
to define a correct aspect, which in general should not happen since refactoring is to make code cleaner. It is also not
scalable Scalability is the property of a system to handle a growing amount of work by adding resources to the system. In an economic context, a scalable business model implies that a company can increase sales given increased resources. For example, a ...
when there are multiple aspects to be applied on the same code and each aspect requires a different refactoring. In general every aspect will be tightly coupled with an application’s structure as the pointcuts explicitly contain a method’s signature, so when an application changes the pointcut needs to be changed as well. This can be quite problematic for a developer.


References


External links

*Paper
Back to the Future: Pointcuts as Predicates over Traces
by Karl Klose and
Klaus Ostermann Klaus is a German, Dutch and Scandinavian given name and surname. It originated as a short form of Nikolaus, a German form of the Greek given name Nicholas. Notable persons whose family name is Klaus *Billy Klaus (1928–2006), American baseb ...
*Paper
Remote Pointcut - A Language Construct for Distributed AOP
by
Muga Nishizawa Muga or MUGA may refer to: * Assam silk * Bodegas Muga, a Rioja winery * MUGA scan * Muga, Nepal, village * Muga (river) The Muga is a river in Catalonia, Spain, that rises in the Alberes mountains of the eastern Pyrenees and enters the Mediterra ...
,
Shigeru Chiba , known by the stage name , is a Japanese actor, voice actor, talent and sound director from Kikuchi, Kumamoto. He is affiliated with the talent management firm 81 Produce. He is most known for the roles of Yoshihiro Kira from '' JoJo's Bizar ...
and Michiaki Tatsubori *Paper
Datalog as a Pointcut Language in Aspect-Oriented Programming
*Paper

by
Karl J. Lieberherr Karl may refer to: People * Karl (given name), including a list of people and characters with the name * Karl der Große, commonly known in English as Charlemagne * Karl Marx, German philosopher and political writer * Karl of Austria, last Austr ...
, Jeffrey Palm and Ravi Sundaram {{aosd Aspect-oriented software development Aspect-oriented programming