• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Document or not? gazillion public constants in one class

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ;-)
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic