Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [singleton]

The singleton is a design pattern to ensure that exactly one application-wide instance of a particular class exists.

Filter by
Sorted by
Tagged with
12 votes
4 answers

Sound manager for Android

I created a singleton class for managing sound effects on Android. This class will only be instanced and loaded once at the beginning, and each activity will use the loaded songs. I don't know either ...
FR073N's user avatar
  • 231
67 votes
9 answers

Implementing a Singleton pattern in C#

Is this the best way to implement this pattern in C#? ...
Aim Kai's user avatar
  • 772
31 votes
1 answer

Single-instance WPF application

This is the code I implemented so far to create a single instance WPF application: ...
Tommaso Belluzzo's user avatar
18 votes
3 answers

Singleton using enum

Is this the correct implementation of a singleton using enum? ...
Nishant's user avatar
  • 477
7 votes
1 answer

Prime Numbers Store

Let's say we need to create a store for selling prime numbers. Users enter the store and ask to buy a number. If the number asked is a prime number, 1.1. then it's either available for sale 1.2. ...
rycle's user avatar
  • 145
6 votes
2 answers

Singleton design pattern

I am a beginner in PHP-OOP and design patterns. I have got this basic piece of code in Singleton Pattern and I changed it in order to understand its behavior. I can see that it works as expected. ...
DanielTheRocketMan's user avatar
6 votes
2 answers

Building in the built-in declarations

In order for Rubberduck to be able to "recognize" the built-in VBA functions, procedures and objects, I added yet another constructor parameter to my Declaration ...
Mathieu Guindon's user avatar
5 votes
2 answers

Using a singleton class to get and set program wide settings

The following code works and does what I want, but I'd like to confirm I'm using this OOP concept correctly. I'm using the following class to get and set some configuration parameters for my program. ...
user1028270's user avatar
3 votes
2 answers

Simple singleton database connection pool

I'm studying design patterns, and to demonstrate a singleton, I've implemented a primitive database connection pool. ...
Levent Divilioglu's user avatar