|
|
|
|
|
by kazinator
33 days ago
|
|
I went to an AOP talk by Kiczales back in 2005. When he presented join points as being driven by regular expression matches on identifiers (e.g. Get*: for all methods starting with Get) I decided to heckle. Knowing he has a Lisp background I brought up how Lisp teaches us that symbols should be treated as atoms; good programs don't break atoms apart. I think he made some Lisp joke and brushed it aside. But it's actually an incredibly bad idea. - Want to add a new method? Maybe it's covered by an existing joinpoint expression and pulled into a pointcut, before you've even written it. - Want to rename something? Where is it referenced? You can't just search for its name as a whole-identifier match, but must find every join point expression that could contain a regular expression match for it, and then filter out those whose other conditions don't match (wrong class, or whatever). It is really hokey; and AOP tooling is possible without it, just more cumbersome. E.g. we can have a special annotation which indicates that method is a joinpoint target, written somewhere on the method. That annotation can list the pointcuts to which it belongs. That becomes more maintainable. The reader of the code knows that since the method is a joinpoint, it interacts with certain pointcuts. They are listed by name, so you can jump to their definitions. When someone adds a new method to that class, they will see that the existing methods have this cruft on them, and decide whether to crib it, and how much. Just because the new method has a certain name doesn't mean it should be in those point cuts, or maybe not all of them. |
|
I really enjoy hearing these kinds of war stories from senior programmers. I don't have a LISP background, but having learned Haskell, your point resonates perfectly.
In the Haskell mindset, letting string-matching rules alter the actual semantics of a program is fundamentally wrong. (At least, that's how I'm interpreting your LISP analogy since I don't know the LISP side well.)
I completely agree with you. Changing the meaning of logic based on string patterns is definitely an anti-pattern. (Though, to be brutally honest, when deadlines are incredibly tight, I've definitely caught myself mindlessly doing it too.)