This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes and what do you think about Constants class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "and what do you think about Constants class?" Watch "and what do you think about Constants class?" New topic
Author

and what do you think about Constants class?

Pavlo Rybakov
Greenhorn

Joined: May 31, 2010
Posts: 24
Hi all,

What do you think about Constants class which contains all possible constants?
Why it can be a wrong way?

Thanks,
Pavlo.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

I creates a centralized and global repository. Yuk! Constants, as with any other elements, should be declared close to, and at the lowest, scope where they make sense.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5216
    
  12

I created a Constants class in my gui package and also a Messages class. The first one contains a bit of useful constants, the other one contains hard-coded captions, titles, error messages,... so it will be quiet easy to adapt i18n to the application (if necessary in a future release)


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: and what do you think about Constants class?