When using AOP we will not know what is the full functionality of a class, and we cannot be sure that can we refactor this class or not.
Because just looking at the code will not see what will actually happen at run-time. And refactoring might break additional functionality from the defined aspects/pointcuts.
Is there any way to solve these problems? Can we write comments to state that this class use AOP, and list Aspects for the class? But if we do so we need to maintain the comments, and the comments can be out of sync.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
You have two options:
1. Use AspectJ tools, especially AJDT that will show you how classes are interacting with aspects
2. Use annotations and select join point based on those annotations. This way, class developer will see code such as @Transactional (almost similar to comments idea you mentioned) and know that certain AOP functionality is applied there.
Many thanks. For the first option, it requires additional tools which is not convenient in many cases. For example, AJDT is for Eclipse only, if we use other IDEs or text editors like Notepad++, vi we'll miss the information.
Using annotations is a good idea, it will work for every editor. I'll try next time I use AOP. Thanks a lot.