Googling doesn't make you a genius. But not Googling makes you dumber.
Prabaharan Gopalan wrote:[..]a utility class and you could still have the properties read exactly once.. and that too only when the first time the properties is accessed. From then on, you could just check if it's already loaded, and if yes, you can retrieve it from memory.
Googling doesn't make you a genius. But not Googling makes you dumber.
Googling doesn't make you a genius. But not Googling makes you dumber.
Michael Parmeley wrote:Telling someone not to use a singleton for this use case is just pure and utter purist nonsense. Keep it Simple and just use a singleton for this scenario.
Repeatedly saying "global state is evil" without really saying why it would be harmful in this use case is ridiculous.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stanley Walker wrote:I have two property files which will be used frequently from a web application....Is there some way in which i can cache these values in server?
Stephan van Hulst wrote:Do you really have that many methods that require access to an object that bundles all configuration settings?
Steve
Paul Clapham wrote:But remember that
However all the discussion in this thread about why you shouldn't use a singleton is useful. Inevitably when you implement my solution of loading the properties when the application starts, somebody decides that they have to change something in the properties. And then they find out that the web application doesn't pay any attention to those changes until it gets restarted. And often restarting a web application is problematic for various reasons.
Winston Gutkowski wrote:
Michael Parmeley wrote:Telling someone not to use a singleton for this use case is just pure and utter purist nonsense. Keep it Simple and just use a singleton for this scenario.
No, DON'T. That's simply substituting simplicity for ignorance.
Actually, Stephan has suggested several very good articles on the subject. If you don't want to read 'em, and just go with a 'System' or 'Application' class/object because it's "simpler", that's your look-out.
Programmer B debugs a method from the program several months later by testing it with dummy config files. The entire program run suffers side effects during testing because the dummy config files are referenced from many other methods.
Stephan van Hulst wrote:No, it suggests that the same properties singleton is being used in different parts of the program, for different purposes. This is my point.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |