This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am using ant to build a program. When I rebuild after having changed some constants in my program, the program still uses the old values of the constants. If I do a clean and rebuild the new values are used. How can I set things up so that I don't need to do a clean before I rebuild?
The problem is that if you have "final" constants, their value gets compiled into the classes that use them directly - the resulting class file does not have a reference to the class they came from. So if that final value changes in the source code, all classes that use it need to be recompiled in order to pick up the new value. Either force a clean compile whenever you change a final constant, or don't make the constants final. A really good build tool could detect this situation automatically and recompile as necessary, but I'm not aware of one that does this.