Pointcut: Difference between revisions

Content deleted Content added
Neinsun (talk | contribs)
mNo edit summary
Neinsun (talk | contribs)
No edit summary
Line 1:
In [[aspect-oriented programming|aspect-oriented]] [[computer programming]], a '''pointcut''' is a [[set (mathematics)|set]] of [[join point]]s. Pointcut allows where exactly to apply aspect advice, this allows separation of concerns and helps in modularizing business logic.<ref>{{Cite web|url=http://www.daimi.au.dk/~eernst/splat05/papers/Stoerzer.pdf|title=A Classification of Pointcut Language Constructs|last=|first=|date=|website=|publisher=|access-date=13 September 2016}}</ref> 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]] syntax is considered as de facto standard. Frameworks are available for various programming languages like [[Java (programming language)| Java]], [[Perl]], [[Ruby (programming language)|Ruby]], and many more which support pointcut.
 
== Background ==
Line 7:
Whenever the [[computer program|program]] execution reaches one of the join points described in the pointcut, a piece of [[code]] associated with the pointcut (called [[Advice in aspect-oriented programming|advice]]) is executed. This allows a programmer to describe where and when additional code should be executed in addition to an already defined behavior. This permits the addition of [[aspect (computer science)|aspect]]s to existing software, or the [[design]] of [[software]] with a clear [[separation of concerns]], wherein the programmer [[aspect weaver|weaves]] (merges) different [[aspect (computer science)|aspect]]s into a complete [[application software|application]].
 
Suppose there is an application where we can modify records in database. Whenever users modify the database and we want to have a log of information, regarding who is modifying the records. Traditional way to log is to call log method just before modify database method. With the Aspect oriented programming, we can apply pointcut to modify database method and have an advice that is called to log the required information.
 
== Expressions ==
Line 36:
Pointcut will match when code executing belongs to UserType.
== Criticisms ==
Pointcut languages impacts important software properties like evolvability and comprehensibility, in a negative way. There might be a possibility where there is a need to perform refactoring to define a correct aspect, which in general should not happen since refactoring is to make code cleaner. It is also not scalable when there are multiple aspects to be applied on the same code and each aspect requiring a different refactoring.<ref name=":0">{{Cite web|url=http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.2.594|title=Inductively generated PointCuts to support refactoring to Aspects|last=|first=|date=|website=|publisher=|access-date=14 September 2016}}</ref> 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 is quite problematic for a developer.<ref name=":0" />
 
==References==