This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a bunch of constants that need to be used by many classes. Does it make sense to create an interface with these constants even though the interface would have no methods. I understand an interface is supposed to act as a template for some behavior, this use would be a bit more limited. If classes need to share global variables, and an interface is not the way to go, what is typically done? Thanks.
Take a look at this related conversation in the intermediate forum. And you may want to consider that object behavior is at times preferred over state-based solutions (not to mention a lot more interesting to explore and think about).
It's certainly important to notice this problems. But you should also notice that a) the serialization problem has a very simple solution (also presented in the article), and b) the classloader problem should be rather rare So, in my not so humble opinion, you shouldn't miss this powerfull pattern just because you fear that it might not be appropriate sometime in the future. YMMV
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus