Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make classes in projects using AOP clear?

 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramnivas Laddad
Author
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

-Ramnivas
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic