Aspect Oriented Programming (Flow Framework)
Created on 2023-10-22T02:38:47-05:00
aspect oriented programming is primarily to deal with "cross cutting" concerns. These are things you need to do (perform security credential checks, audit logs) when doing normal behavior, but are not actually part of the business logic and otherwise clutter up the code.
Top Level Concepts
Aspect: a top level container that contains advice and policy where to install that advice.
Join point: somewhere in the control flow you can hook advice to.
Advice: behavior--can attach itself around or replace the original intended behavior.
Point Cut: criteria for attaching advice. Basically, what join points should be affected by a given advice function.
Point Cut Expression: a way of specifying what join points a point cut matches
Weaving: a process that takes the relevant aspects and business code, and jams all of the behavior together in to a final object that does everything it should.
Advice
Injecting behavior around a call site is called "advising" the function.
"Advice" can happen before, after [always/success/failure], or entirely replace if the original behavior is even called ("around.")
Advice may be chained such that behavior is stacked where one advisor aborts a control flow or calls in to the next advice/function.
Areas that advice can be installed are called "join points."
more
AOP is basically splitting code concerns in to separate things that stack together. You write business logic to manage an account and separate logic that performs logging on failure/success signals. Some kind of query logic specifies which areas of code to be rewritten and "advice" is the code which is inserted there. A "weaving" process refactors code by looking for query matches and replacing code with advice functions.