| Author |
Library needs access to differnet constants
|
kevin Kinnett
Greenhorn
Joined: May 03, 2005
Posts: 2
|
|
Hello, I have found myself using the same code over and over in different programs I am writing. So I decided to create a library. This is the first time I am doing this so I have a question. The individual classes in the library need to have a different configuration depending on what program is using it. For instance I have a Swing widget that uses a custom icon. Up to now I have been using a constant class in the library that the library refers back to, however I would like to put that constant class in each project I am working on and have the library look back to it. Is there a good way to do this? I have found that reading from a file each time is inefficient, especially if it is something like a simple sting. Thanks
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26138
|
|
Kevin, Welcome to JavaRanch! You are actually on the right track with the file idea. You can cache the value the first time you read it by storing it in a static variable. That minimizes the performance hit because it only happens once.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
It sounds like these values are not constant since they differ depending on which program is running. My suggestion would be to create a class with the "constants" for each program. That program then passes the values as parameters to the methods in the library. What do you think? Layne
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: Library needs access to differnet constants
|
|
|