#Singleton / Design Pattern (Code Review)

1 messages · Page 1 of 1 (latest)

cloud drum
#

Hello, I just want some feedback on if I'm creating/using this singleton class (ChunkUpgradePool.java) right. I've avoided using them forever cause people say they are bad lol. https://github.com/Z-laio/chunkwars

GitHub

Contribute to Z-laio/chunkwars development by creating an account on GitHub.

proven yoke
#

Singleton isn't bad imho as long as you use it properly, but to each there own

#

its really what you think is best

cloud drum
#

really im tryna use them cause i have some classes that i only instantiate once and am sick of referencing them through di from the main plugin object

#

especially when it doesn't always make sense for an object to need an instance of the main plugin

proven yoke
#

you are kind of abusing DI if thats what you are doing

#

you should only really be passing in what you absolutely need

cloud drum
#

yeah but sometimes ill have like 3 things i need all stored in the main, i just pass in the main cause its 1 param vs 3

proven yoke
#

Personally I'd just stick with DI, but if you absolutely need to just use a singleton

#

its not a huge deal