Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
72 views

I am refactoring code and implementing repositories. Database access is handled via this singleton: class SQLiteConnectorV2 { private static instance: SQLiteConnectorV2 | null = null; public db: ...
Aleix's user avatar
  • 1
2 votes
3 answers
256 views

This question is about the singleton pattern in modern C++ and one of its limitations in particular. I can implement the singleton pattern like this: class Logger { public: static Logger& ...
Hendrik's user avatar
  • 806
0 votes
3 answers
277 views

I am storing some settings for my application in a JSON file located alongside the application .exe. I want to load these settings only once, lazily, the first time one of them is needed. So for ...
Theodor Zoulias's user avatar
Best practices
2 votes
4 replies
153 views

Follow-up on this question: Singletons: good design or a crutch? It is true, that using singletons can make testing harder, and bugs can hide behind them. GoF defines singleton to use when: Global ...
zerocukor287's user avatar
  • 1,839
0 votes
0 answers
130 views

Here's a piece of Qt code: int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QGuiApplication app2(argc, argv); The first constructor call returns, the second does not. I ...
Ivan's user avatar
  • 633
2 votes
1 answer
93 views

I want to instantiate class with default value. Class have required parameters. Class must be singleton (can be implemented with smt other than metaclass). Data must be updated if try to instantiate ...
big_cat's user avatar
  • 57
0 votes
0 answers
130 views

According to [1]: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines, the recommended approach for handling HTTP requests is to use singleton or static ...
florins's user avatar
  • 1,665
1 vote
2 answers
166 views

Everyone knows Singletons. Here is one: public class MySingleton { private MySingleton() { } public static MySingleton GetInstance() { return instance ??= new MySingleton(); } ...
Thomas W.'s user avatar
  • 61.3k
0 votes
0 answers
60 views

This is a Kotlin question, although it originated from Android Jetpack Compose. I defined the Context.dataStore extension property in the recommended way: val Context.dataStore: DataStore<...
18446744073709551615's user avatar
1 vote
1 answer
84 views

I have a tracker which I'd like to be a singleton class for usage throughout the app. For instance, I came up with the following: export class MyTracker = { private static instance: MyTracker | ...
EDJ's user avatar
  • 1,073
0 votes
0 answers
54 views

I'm trying to browse the C++ code for an embedded project using Doxygen 1.8.13. I find the call/caller graphs very useful for this, but the project includes several singleton classes. Each of these ...
Dave Tweed's user avatar
2 votes
3 answers
238 views

Does the singleton pattern in C++ have processor overhead? If it does, how much? static Singleton& getInstance() { static Singleton instance; return instance; } //... int ...
fiqcerzvgm's user avatar
2 votes
2 answers
94 views

For .NET Generic Host it is possible to register multiple implementations of same service interface. When materializing that service the last added is obtained (that is correct even for multiple ...
bairog's user avatar
  • 3,593
0 votes
2 answers
173 views

I have a class AppData that I am going to load as Singleton to store data for use across my Blazor web app. My issue is that the singleton requires some data that is retrieved with asynchronous calls ...
GarudaLead's user avatar
0 votes
1 answer
108 views

I need to perform some action (i. e., log succesfull shutdown) when all registered services in .NET Generic Host are disposed. I hoped IHostApplicationLifetime.ApplicationStopped could help me but it ...
bairog's user avatar
  • 3,593

15 30 50 per page
1
2 3 4 5
584