Not necessarily a bad practice if the singleton is immutable, and it’s provided via dependency injection for example.
Comment on The temptation is always there
idunnololz@lemmy.world 1 year ago
Just create a global object and stuff your variable in there. Now you have a global singleton and that’s not a purely bad practice :D
magic_lobster_party@kbin.social 1 year ago
wreckedcarzz@lemmy.world 1 year ago
As a hobby coder: “mmmhm, mmmm, mmhm… I know some of these words!”
Anonymousllama@lemmy.world 1 year ago
Important to contain all your mess to one side of the room, makes it easier to manage
shotgun_crab@lemmy.world 1 year ago
Yeah yeah let’s put all the eggs in one basket
mdk_@lemmy.world 1 year ago
So you saying, just the tip?
xmunk@sh.itjust.works 1 year ago
Real enterprise programmers know that everything should be on the stack… so they declare a List in main.
manapropos@lemmy.basedcount.com 1 year ago
Real enterprise programmers know you can get another job in the next year or two so fuck best practice
idunnololz@lemmy.world 1 year ago
But we might need to add more features in the future so it might not just be a list in a few years. Better encapsulate it in a few layers of abstractions just to be safe.
HurgletOfficial@lemmy.basedcount.com 1 year ago
I do this all the time in Python by creating a class like
class Core: foo = "bar"
ryannathans@aussie.zone 1 year ago
That’s not immutable nor a singleton
xmunk@sh.itjust.works 1 year ago
That makes it inherently multithread compatible!
Techmaster@lemm.ee 1 year ago
Just call it “state management” and nobody will even care.