Pointcut

In aspect-oriented programming, a pointcut is a set of join points.

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

In aspect-oriented programming, a pointcut is a set of join points. A pointcut specifies where exactly to apply an 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 names.

Different frameworks support different Pointcut expressions; AspectJ syntax is considered as de facto standard. Frameworks are available for various programming languages like Java, Perl, Ruby, and many more which support pointcuts .

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, wherein the programmer weaves (merges) different aspects into a complete application. 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.

Paper "Back to the Future: Pointcuts as Predicates over Traces" by Karl Klose and Klaus Ostermann Paper "Remote Pointcut - A Language Construct for Distributed AOP" by Muga Nishizawa, Shigeru Chiba and Michiaki Tatsubori Paper "Datalog as a Pointcut Language in Aspect-Oriented Programming" Paper "Expressiveness and Complexity of Crosscut Languages" by Karl J. Lieberherr, Jeffrey Palm and Ravi Sundaram

Text derived from https://en.wikipedia.org/w/index.php?oldid=1376416966 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

5 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.