In a previous terminology post on "advice", I pluralized advice to "advices" without even thinking about it.
Alexey Berezkin asks what the plural of "advice" actually should be, since "advices" isn't actually a valid English word. My answer is that "advices" is okay in the context of aspect-oriented programming, since it's basically jargon at that point.
Probably most correct would be "advice classes" or "advice instances", depending on the context. Advice classes are what I write using PostSharp, and advice instances are what get instantiated by the code that PostSharp's post compiler weaves into the rest of the code. "Advices" is sort of an overarching piece of jargon that covers both.
I continue to try and 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: advice.
An advice is simply the code that could be executed at a pointcut. For instance, if you want to do some logging, then your advice is the code that performs the logging. If you are wrapping methods inside of a transaction, then your advice is whatever implementation of begin/commit/rollback you are using. And so on...
Here's a quick example of a tracing aspect I borrowed from the PostSharp site:
There's two advices in that aspect:
- One to write "Entering" and the method name to the trace, using Trace.TraceInformation(...)
- One to write "Exiting" and the method name to the trace, using Trace.TraceInformation(...)
Those are both very trivial advices, of course. A more complex advice could reference services, perform logic, use a lot more context information than just method name, etc.
So now that you know what a join point, a pointcut, and an advice is, you have all the puzzle pieces. The final step is to put them all together. And guess what it's called when you put them all together? (spoiler alert: it's the "A" in "AOP")