The concept of function interception turns upon the notion that when a function is called, another sequence
of instructions executes before the callee, thus forming a 'prefix' to that function. Alternatively, the
extraneous sequence can execute subsequently, in which case it forms a 'suffix'. The second diagram illustrates
this concept.
Obviously, this is possible using a conventional approach where a call to the prefix and/or suffix is included
in the body of MyFunc. However, this pollutes MyFunc
with extra code, with all of the associated implications therein. Moreover, if this approach is repeated across many
functions, this hampers development seriously, because inclusion, management, and maintenence of the prefix and suffix-calling
code becomes tedious and tiresome rapidly, and is therefore error prone.
However, the use of advanced JavaScript techniques makes it possible to apply prefixes and suffixes 'behind the scenes',
without the disadvantage of entangled design-elements, cluttered code, and all the problems that these cause. AspectJS
encapsulates the functionality for achieving this simply, efficiently, and with great flexibility.
Note that within the scope of AspectJS, the intercepted method is called the 'interceptee', and prefixes and suffixes
are referred to collectively as 'affixes'. Where the interceptee has one or more prefixes and one or more suffixes then
it is said to be 'wrapped'.