Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Rick O'Shay:
Static methods have no such scalability issues and they provide no facilities for sharing state. Not much of anything in common with singleton.
Tony Morris
Java Q&A (FAQ, Trivia)
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Ronnie Ho:
If I am building a web based application, I'll load up all the objects from the database during startup and those objects stay in memory forever as singleton objects. Whenever I do modifications, I'll update those objects as well as the database. I do that to avoid query the database every time if the request doesn't require modifications to the objects. Do you guys think it's a bad design? Or what's a better solution? Thanks.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Could I use a pre-existing caching implementation instead of building (and maintaining/bugfixing) my own?
Originally posted by Ronnie Ho:
If I am building a web based application, I'll load up all the objects from the database during startup and those objects stay in memory forever as singleton objects. Whenever I do modifications, I'll update those objects as well as the database. I do that to avoid query the database every time if the request doesn't require modifications to the objects. Do you guys think it's a bad design? Or what's a better solution? Thanks.
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
Originally posted by Rick O'Shay:
Always make your methods static unless you can't. In other words you need access to the object's state.
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
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Pradip Bhat:
I need to implement a set of utility methods which do not have any state. What is better approach - A class with a set of static methods or a singelton.