What is the benefit of using the Singleton pattern like this:
What is the benefit of having an internal class compared to just returning a new ConfigManager()
17 Replies
⌛
This post has been reserved for your question.
Hey @userexit! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
so like in the first class have private static final ConfigManager INSTANCE;
then inside getInstance()
if null then create new else return current
I don't really think there is a benefit to this
seems pretty pointless
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
well it's fine if you aren't using multiple threads anyway
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
(by lazy he means that the object isn't loaded when the object is needed, but is instead loaded anyway which is also true)
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
how would you adapt this code to be an enum
?
what does the constructor do
well nothing in this case
it just constructs the object
you can remove the constructor in this case
and a thing to note as borgel said generally speaking if you have to use a singleton you should probably restructure your code
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
its just to load properties files
that i will use across my program
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
i do
Properties
instance no ?
Properties properties = new Properties();
properties.load(fileInputStream)
properties.getProperty(String key)...
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.