It's a pretty common (and usually, good) practice amongst java programmers to organize all of the little magic values that application logic depends on into a class that defines public constants. However, this can lead to another problem: constants bloat. Cases where the developer needs to define a constant that is only accessed by one component (let's just call a single class and its instances "one component" for the time being) but stores it in a shared centralized constants class is another form of substance abuse. It's constants abuse.
I would really prefer to see constants with a limited scope of applicability confined to that scope. For instance, if it's only used by one class -- define it in that class, not the shared centralized beast. If it's only used by a cluster of classes that work on a particular area, perhaps there's already a bean that they all know about; the constant may be better suited for that bean than a class shared system-wide.
Confine the scope of your constants definitions to where they are useful and save yourself and your colleagues maintenance headaches down the road.
( Feb 23 2004, 10:55:14 AM PST )