so many forget about this or call it an "antipattern" but they really just don't understand

Nov 8, 2025 · 10:59 AM UTC

Replying to @techsavvytravvy
that's called a singleton and it is mostly Bad
15
14
seems pretty neat
2
Replying to @techsavvytravvy
are you afraid of constructors? why not just always initialize it once?
1
9
there's a constructor right there! i generally dislike constructors tho bc they have weird constraints like can't be async and can't be overloaded
2
10
Replying to @techsavvytravvy
psh, static
pretty good
2
Replying to @techsavvytravvy
Why do you need an instance if you're defining a static Logger. Why do you even need to initialize?
believe it or not, this code is simplified and an actual logger class would probably have methods for logging
Replying to @techsavvytravvy
I’d probably use a private instance + use a getter. private static _instance static get instance{}
1
1
could absolutely do that
1
2
Replying to @techsavvytravvy
Singleton? Literally nobody does or says that. 😂
demonstrably false just by lookin at the comments here
1
3
Replying to @techsavvytravvy
This is ts/js you can have a single anonymous instance, no need of this pattern.
Replying to @techsavvytravvy
imagine only having one Logger tho , u gotta make an interface so u can provide a TestLogger ,ConsoleLogger, BackendLogger ... etc 😤
1
1
class is the interface
1
2