singleton Questions
2
Solved
The FastAPI application I started working on, uses several services, which I want to initialize only once, when the application starts and then use the methods of this object in different places.
I...
Homologate asked 23/5, 2021 at 20:16
6
Solved
class Peoples {
late int id;
late String name;
static final Peoples _inst = Peoples._internal();
Peoples._internal();
factory Peoples() {
return _inst;
}
}
I have this singleton class. W...
3
Why is Bill Pugh's Singleton design pattern thread safe?
public class Logger {
private Logger() {
// private constructor
}
// static inner class - inner classes are not loaded until they are
...
Josephjosepha asked 9/6, 2018 at 6:0
9
Solved
I'd like to know what's the best way (read most elegant) to have a single instance of a given Window per application in WPF.
I'm a newcomer to .NET and WPF and what I came up with looks pretty lam...
10
Solved
What is the preferred way to work with Singleton class in multithreaded environment?
Suppose if I have 3 threads, and all of them try to access getInstance() method of singleton class at the same ...
Keelby asked 17/6, 2012 at 14:59
8
Solved
I'm working in a web app framework, and part of it consists of a number of services, all implemented as singletons. They all extend a Service class, where the singleton behaviour is implemented, lo...
Surcharge asked 27/6, 2010 at 2:5
4
What's the difference between these two? I think they both annotate a singleton object/instance, but somehow @Singleton can be used to annotate methods, instead of classes. I'm really confused abou...
Nationwide asked 25/11, 2020 at 18:19
4
Solved
After reading this answer I have tried implementing some simple CRTP usage. I figured I'd try to implement the Singleton (yes, I know - it's just for practice and research) pattern, given the fact ...
26
Solved
What is the best and most convenient way to implement a Singleton pattern for a class in TypeScript? (Both with and without lazy initialisation).
Kingbolt asked 11/5, 2015 at 17:35
4
I am using Angular 2 to build my web application which which has lot of components. I am using angular-cli to create, run and build the project.
Accidentally (or luckily) I stumbled across a bug wh...
Isleana asked 31/1, 2017 at 10:2
42
Solved
This question is not for the discussion of whether or not the singleton design pattern is desirable, is an anti-pattern, or for any religious wars, but to discuss how this pattern is best implement...
Pap asked 20/7, 2011 at 10:47
2
Solved
I was told to use the singleton pattern instead of having global objects, which have the “static” storage duration, to avoid the static initialization order fiasco. But now that I have C++20 module...
Paloma asked 9/3 at 6:37
10
Solved
For desktop application that is. This is just a general question that maybe only need general answers.
Disfeature asked 13/12, 2008 at 14:32
13
What are the different ways we can break a singleton pattern in Java.
I know one way i.e. if we do not synchronize the method in singleton , then we can create more than an instance of the class. ...
2
I have a class like this:
from __future__ import annotations
import os
from dataclasses import dataclass
@dataclass(frozen=True)
class Config:
name: str
age: str
@staticmethod
def init() -&...
Wallis asked 11/5, 2021 at 19:53
5
Solved
We all know about log, ok, but why should we consider the «Logger» class a singleton one? What happens if we make it as a normal non-singleton class?
Gurrola asked 3/11, 2010 at 9:4
1
I'm working on this Python module, which compounded from several files. Few of those files are actually independents, and meant to do a very specific job. I know for a fact that there will be only ...
Lion asked 29/1, 2017 at 9:8
30
Solved
The singleton pattern ensures only one instance of a class is ever created. How do I build this in Dart?
5
Solved
Assume I have a data class:
data class SensorData(val name: String, val temp : Double)
I create this SensorData object from either an REST service or by internal setter method, whereas name is a...
Master asked 23/5, 2019 at 8:47
4
Solved
What's the best practice for implementing Singletons in Perl?
13
Solved
How to avoid multiple instances of windows form in c# ?? i want only one instance of the form running. Because there are chances of opening the same form from many pages of my application.
5
Solved
I have a following sealed class:
sealed class ViewModel {
data class Loaded(val value : String) : ViewModel()
object Loading : ViewModel()
}
How can I serialize/deserialize instances of the ...
Buffington asked 3/5, 2018 at 14:26
13
Solved
I want to store a single row in a configuration table for my application. I would like to enforce that this table can contain only one row.
What is the simplest way to enforce the single row cons...
Stendhal asked 19/10, 2010 at 10:25
5
Solved
i've this implementation of singleton pattern in python, but i've noticed
that the init is called, uselessly, everytime i call MyClass, despite the same instance is returned.
How can i avoid it?
...
Entozoic asked 7/7, 2015 at 13:30
10
Solved
I want
Stats.singleton.twitter_count += 1
and I thought I could do
class Stats:
singleton_object = None
@property
@staticmethod
def singleton():
if Stats.singleton_object:
return Stats.s...
Summitry asked 8/11, 2009 at 18:52
1 Next >
© 2022 - 2024 — McMap. All rights reserved.