I’d like to know peoples’ preference on applying AOP.
For instance. if hit count should be increased upon reading an article, Should I apply AOP to view method? Or just call the increaseHitCount() within view()?
In my point of view on this matter, I guess increaseHitCount() isn’t a main purpose of view() method but ancillary matter.
public DAO dao;
public Article view() {
dao.increaseHitCount(); //<-- I think this is not for here.
return dao.getArticle();
}
However, I’m just worrying that the code is getting hard to understand and read by AOPs applied throughout the sources.
AOP will help you make your code more orthogonal, and also helps fighting code duplication. My experience is that aspects are used for general system-wise features. Think about whether the hit count is loosely coupled to the rest of the page logic or not and is it general enough. If yes is acceptable (or preferable) to use it as an aspect. On the other hand AOP brings overhead, but AspectJ for instance is really fast.
I this case I would consider AOP if it is otherwise used in the project.