Iβm looking for a way to somehow tag code that can be optimized so that I or someone who comes to me in the project knows what and how to optimize when performance becomes a problem.
The reason I'm not optimizing right now is that code clarity is more important in most cases than code optimization based on my and many other experiences (for example, check Joshua Block "Effective Java Programming"). So, I prefer to keep the code clear and understandable (which basically means that it implements things the way someone does it; don't try any fancy things until you really need it). Although when performance becomes a problem, itβs good to know where to look and do optimizations due to a loss of code clarity. I would like to point out places where you can optimize the code, and give some tips on how to do this.
The way I thought it was to use annotation like:
public class UserDao { @Optimizable (hint="cache returned data; ") public List<User> getUsers(int userType) {
Is there a standard - widely used in the community - to label your code for this? Or do you have a better idea of ββhow to do this?
Using annotations makes it easy to check optimized code and generate several reports for this. Another way might be to use the javadoc shortcut, but not sure how easily the tool can detect this.
Thanks Stef.
ADDED:
Well, it seems that Rick's answer covers all the ways to do this in the comments. What about annotations? I believe that this has some advantages, since you can find problems with code / optimization parameters, even if you do not have source code and optimization, offering a new implementation for these methods / classes and using polymorphism. Do you know if there are any standard annotations for these?
source share