Skip to main content

Questions tagged [singleton]

The singleton is a design pattern aiming to ensure that only a single instance of a class can be created and used.

0 votes
1 answer
588 views

Background: I am working in a Java environment using Spring Boot, where I often encounter scenarios where global variable state management is critical, especially within singleton services. I have ...
procrastinator1771's user avatar
0 votes
2 answers
814 views

I have a singleton that needs to be initialized at the start of the program and it will live on until the end of the program. As is usual in this pattern, a function initializing the singleton creates ...
Reverent Lapwing's user avatar
1 vote
4 answers
1k views

I make sure when designing software/firmware to make heavy use of dependency injection so that different pieces of the application are not directly coupled to one another. This also allows me to (...
Patrick Wright's user avatar
1 vote
2 answers
524 views

I have found myself in the habit of using code like this. class glb: "just for holding globals" args = None # from argparse conf = None # from configparser def main(): ......
Alias_Knagg's user avatar
-1 votes
3 answers
965 views

Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining ...
Veverke's user avatar
  • 541
-2 votes
3 answers
1k views

It can be found in many advices on topic that having Singletons is an anti-pattern. Especially for cases of testability. Can someone please advice/critique on this way (please see code below) of ...
psb's user avatar
  • 101
2 votes
0 answers
349 views

I have a Repository service that should be Transient. It is used in many applications. I have a new application that's a Console App, and current guidance suggests implementing my business logic in ...
catfood's user avatar
  • 1,615
2 votes
2 answers
1k views

There is a parent window that is the basis of the program, and there are several sub windows under it. Editor is one of the sub window and I'm making it. The code is as follows: // This is Code-Behind ...
wddfrwd's user avatar
  • 71

15 30 50 per page
1
2 3 4 5
10