| Author |
Document or not? gazillion public constants in one class
|
Arkin Yetis
Greenhorn
Joined: Oct 13, 2010
Posts: 4
|
|
I have centralized all my GUI constants and texts shown to the user in one interface as a bunch of "public static final" variables.
The instructions say that "javadoc style comments must be used for each element of the public interface of each class".
So does this mean that I have to write a comment for each of those gazillion constants, which will not be much more than a repetition of the name of the variable (as I believe I have selected reasonably clear names for the variables.)
I would appreciate any insight. Especially if someone has had a problem with such a situation.....
I am thinking that there is a good chance that I am not the first one who used this approach.
|
 |
Piotr Nowicki
Ranch Hand
Joined: Jul 13, 2010
Posts: 610
|
|
In my opinion, I guess that to be 100% sure, you should add those comments to avoid breaking any 'must' requirement...
I'm not working on the GUI yet, but I was rather thinking about using java properties instead of constant values. This will separate the communicates from your code and allows their easy modification and internationalization of (althought it is not a 'must' requirement I just feel it's right).
BTW: Check this out (http://thedailywtf.com/Articles/Enterprise_SQL.aspx) - it's not related to communicates constants though, but it's basicaly about abusing of public constants.
The bottom line is a masterpiece ;-)
|
OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4349
|
|
I documented every constant in my class/interface with gui related constants, although I don't have a gazillion of them
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Arkin Yetis
Greenhorn
Joined: Oct 13, 2010
Posts: 4
|
|
Thanks, guys. I better not take a chance and document all of them.
It was a little less than a gazillion. After some clean-up and moving out of the text, I ended up with only 12, which isn't too bad.
Btw, most of them were action command strings for UI components that are shared across view and controller classes to identify events. Any approaches you can recommend to deal with them other than centralizing them in a single class/interface?
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
Arkin Yetis wrote:Any approaches you can recommend to deal with them other than centralizing them in a single class/interface?
How about using a ResourceBundle?!
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Arkin Yetis
Greenhorn
Joined: Oct 13, 2010
Posts: 4
|
|
Thanks for the suggestion.
I am used to using resource bundles for localization. Since I didn't think of translating/localizing action command strings, I didn't think of moving them there.
But I guess one could consider using resource bundles for all string constants. I have to think about the cost of look up, though, for real-life scenarios....
|
 |
 |
|
|
subject: Document or not? gazillion public constants in one class
|
|
|