Skip to main content
Filter by
Sorted by
Tagged with
Best practices
2 votes
4 replies
107 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,675
3 votes
1 answer
85 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
  • 33
0 votes
0 answers
45 views

Goal Implement a Singleton Design Pattern for a struct, without multiprocessing considerations. Minimal example Here is the base of the code, without the singleton logic. struct ...
GregoirePelegrin's user avatar
0 votes
0 answers
48 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
0 votes
0 answers
44 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
2 answers
79 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,539
0 votes
1 answer
77 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,539
2 votes
1 answer
112 views

I am working on creating some ASP.NET Core 8.0 Web API endpoints (in C#). There will be over 100 endpoints across 40-50 repositories that are all a part of the same platform ecosystem; it is not an ...
Jacob L.'s user avatar
-1 votes
1 answer
101 views

I have a requirement in which I have to use a singleton class, acting as a database to store some values. I have also declared a run function in the cpp file of this singleton class in order to change ...
Tejas Sharma's user avatar
0 votes
2 answers
40 views

I am trying to instantiate a singleton with constructor argument. However, passing the input arguments to the metaclass hits an error. from typing_extensions import List, TypedDict, Optional, Any ...
khteh's user avatar
  • 4,280
0 votes
1 answer
65 views

In F# FSharp.Core(8.0.400) and Windows .NetCore 3.1, the following singleton pattern worked flawlessly: [<AutoOpen>] module AppointmentEventManager open Stargate.XI.Client.Domain.Models type ...
Alan Wayne's user avatar
  • 5,424
0 votes
2 answers
110 views

I have a UIViewController class with a variable shared that allows other classes to reach it as a singleton. However, the compiler (with Main Thread Checker enabled in Scheme Settings) is flagging the ...
user6631314's user avatar
  • 2,050
1 vote
2 answers
160 views

Basic process explanation: A process has some initialization parameters that have to be set dynamically at runtime. For example data for a certain amount of dates (final_lookback) have to be pulled ...
shoshanie's user avatar
0 votes
0 answers
33 views

Problem Description: I am using a singleton SocketConnect class to manage WebSocket connections in my React Native application. The connection works fine initially, but when I leave the app and return ...
Debug_logger's user avatar
-2 votes
1 answer
61 views

The main project ModuleDemo depends on ModuleA, ModuleB, and ModuleC. The description of the entire project's Podfile is roughly as follows: platform :ios, '13.0' use_frameworks! :linkage => :...
zox01's user avatar
  • 64
0 votes
0 answers
79 views

I have object A like this: sealed class B { private val d: String = this::class.simpleName!! data object C: B() } data class A( val b: B, ) And I have faced this error when I want to get object A ...
Mohammad Esteki's user avatar
2 votes
0 answers
149 views

I would like to make sure I understand this correctly. I created a singleton class managing cache of NumberFormatters and compiler complains about shared property not being concurrency-safe. Reasons ...
ofun's user avatar
  • 87
0 votes
1 answer
33 views

I have created a class that I"m attempting to implement a Singleton pattern on. When __new__ for the class is fired off, I check to see if a class-wide list of instances has a length > 0 or ...
GeranTabee's user avatar
-2 votes
2 answers
100 views

I have the following singleton implementation based on a video https://youtu.be/Q6HJpgdkAK8?si=k-9ksjHirLHq5Ne2 Some features of my own implementation are different, but i want to know whether my ...
Oscar RoAh's user avatar
1 vote
0 answers
47 views

how am I able to create an instance of Singleton s3 even when the constructor is private, tried in local env and online compiler as well, it is running public class Singleton { // Step 1: ...
gourav pal's user avatar
-3 votes
1 answer
93 views

I'm a student who is studying game engine structure. I've been managing shared resources through the Singleton Patterns Manager class while creating game engines. However, as the code got longer, the ...
Tee Mo's user avatar
  • 19
2 votes
1 answer
125 views

I have a requirement for an OBJECT to be used by other objects. The requirement is that the OBJECT not require initialization by any external call. So I began with something like so... // .h struct ...
IAbstract's user avatar
  • 19.9k
0 votes
1 answer
107 views

The following code is failing to compile and i am not able to figure out why! /* --------------------------------------------------------------- */ /* Includes */ #include <iostream> #include &...
meetanandkr's user avatar
0 votes
1 answer
53 views

We have a singleton object we use for our program that refers to an ugly god-object that I wish would die - we inherited the code from a team that had already implemented it this way. Unfortunately ...
dsollen's user avatar
  • 6,521
1 vote
1 answer
517 views

I am facing an issue with a NullReferenceException in my code. I've created a LevelManager script to manage the different scenes of my game. Inside this file ScoreKeeper object is called. This ...
Maxence Hermand's user avatar

1
2 3 4 5
175