Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Document or not? gazillion public constants in one class

 
Arkin Yetis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ;-)
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I documented every constant in my class/interface with gui related constants, although I don't have a gazillion of them
 
Arkin Yetis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?!
 
Arkin Yetis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic