Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
2 answers
469 views

Is it considered a code smell to not delete static pointers of a singleton?

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
913 views

Should I use a singleton to represent the application as a whole?

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
-2 votes
3 answers
827 views

Singleton as Interface for testability via dependancy injection

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
1 vote
2 answers
2k views

Best way to access (grand grand) parent element in gui

I'm creating a multi window gui program, in c++ with Qt Widgets. I do have many custom gui elements, which usually are c++ classes inherited from QWidget or other Qt elements. When foo is the main ...
Turtle10000's user avatar
-2 votes
1 answer
235 views

Improve design with singleton pattern

I want to create a media management tool, for which I try to draw an appropriate UML class diagram. The tool shall hold a collection of different media types (movies, music, etc.) which inherit from a ...
Jannek S.'s user avatar
  • 121
1 vote
2 answers
482 views

Overhead of using big singleton with all files includes

I have several subsystem managers for various uses, for example: AudioManager CollisionManager InputManager etc. At first I wanted them to be all singletons, however now want to make the ...
Pins's user avatar
  • 201
-1 votes
4 answers
135 views

Base global system for two customizable subcomponents

The following explanation is rather detailed, but I think if I simplified the problem at hand no proper answer could be given. I'm working on a scripting system for a game (for end users rather than ...
edcruz's user avatar
  • 1
-2 votes
2 answers
1k views

C++ Which of the following is a better singleton pattern approach?

I'm now stuck in the server I am programming, simply because I do not seem to find a good and realiable way to handle my "single object" classes, I've attempted the Singleton pattern but it is just ...
Raúl Sanpedro's user avatar
3 votes
2 answers
2k views

Difference between Singleton pattern and auto_ptr<> resp. unique_ptr<>

I'm maintaining some legacy code of a physical simulation. The calculation object is build as a singleton, to ensure there is only one instance. A co-worker told me, that singleton are completely out-...
Smii's user avatar
  • 51
6 votes
4 answers
4k views

Is there something like a polymorphic Singleton?

I have a resource loader object that loads objects from the disk or from a ZIP archive, depending on the platform. It has state (e.g. the path to the directory or the ZIP archive, and possibly some ...
futlib's user avatar
  • 2,185
0 votes
5 answers
2k views

should singleton be life-time available or should it be destroyable?

Should the singleton be designed so that it can be created and destroyed at any time in program or should it be created so that it is available in life-time of program. Which one is best practice? ...
Manoj R's user avatar
  • 4,056
12 votes
7 answers
17k views

What are the roles of singletons, abstract classes and interfaces?

I am studying OOP in C++ and, even though I am aware of the definitions of these 3 concepts, I cannot really realize when or how to use it. Let's use this class for the example: class Person{ ...
appoll's user avatar
  • 353
7 votes
4 answers
4k views

C++ - Best way to have a central data repository

I'm coding in C++. I have a server that will have clients connect to it, and each client gets spun off into its own thread for communication. This server is hosting a game, so there is information ...
will's user avatar
  • 173