Posts tagged with 'pointcut'
I'm trying to cut through some of the confusion around AOP by providing simple definitions and examples of often obtuse terminology (see also: other terminology posts).
Today's term: pointcut.
A pointcut is a simply a set (or an expression that returns a set) of join points. If a join point is a single line between two boxes on a flowchart, then a pointcut would be a description of a set of those lines.
For instance, if you wanted to put some logging after every time a method in a given class was called, you'd first get a pointcut of all the join points that occur after each method. If there are 5 methods in your class, you have 5 join points that make up the specified pointcut.
So if your aspect defines "OnExit", and you apply that aspect to a class "CustomerRepository", then your pointcut is "whenever a method in CustomerRepository exits". You could narrow that to a single method, or expand it to an entire namespace.
As an exercise, let's examine this snippet of code:
obj1.Method1(); // obj1 is of type Class1 obj1.Method2(); obj2.MethodA(); // obj2 is of type Class2
And now a flow chart of that, identifying exit join points:
So which of those join points would be included in a pointcut of "exiting a method of Class1"? Answer: