|Re: [aspectj-users] creating a pointcut for primitive|
Just a thought...
> Iâd like to be able to avoid having every programmer be responsible
> for determining whether the calculation is financial or not
But it might be nice if, when they know it is a financial calculation,
they can say that in the code in a way that's susceptible to modern
refactoring and AOP tools.
So instead of using BigDecimal directly, you might consider writing your
own static API, e.g.,
x*y -> Financial.multiply(x, y)
Then you can implement it however you want, it's clear what's meant,
and it becomes a join point so you can use AOP to apply or change the policy.
Outside AOP, one advantage is overloading the method so you can
handle your own conversions (and even write your own int wrappers,
e.g., with units). And there's virtually no overhead in modern VM's if
you implement with static/final/private methods.
If you end up extending a compiler, then you have to decide which
int-multiplies (hard to do) or do them all (which might lead to unintended