Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
The singleton is a design pattern aiming to ensure that only a single instance of a class can be created and used.
5
votes
Should I use a singleton to represent the application as a whole?
From what you have written about the responsibilities of the shows classes, I think you mixed up the Singleton pattern with the Factory Method pattern (not to be confused with "Abstract Factory"). … In case you really need global access to the one Application instance throughout your program (for which your question gives actually no indication), then you can make this also Singleton, of course. …
4
votes
Passing central objects around or having global instances?
Why not
public static class Program
{
private static MyCentral _central;
...
var controller = new SomeController(_central);
}
...
public class SomeController
{
MyCentral _central; …
4
votes
How to create a manager class without global variables nor singletons?
it will be in charge of loading textures, processing them, distributing them
Well, I don't know your application, but this hardly sounds like a thing you need everywhere in your application, espe …
10
votes
Accepted
Singleton with dependency injection ,is that a good practice in some cases?
The best way to avoid this is probably not to use the singleton pattern at all, do the one-time initialization containing htdb=new HeavyTaskDb(X) in one defined placed and make the htdb object available … If your really think you need to have a global variable of type HeavyTaskDb in your program (just like your singleton is a global variable), then consider to implement it this way:
public class HeavyTaskDb …
2
votes
Is it right way to make Window to Singleton and call Visibility and Shutdown() methods direc...
Even if you know for sure that there will never be the need fore more than one MyEditor windows - the question you should ask yourself here is:
Does this simplify the code? - Or does it complicate thi …
3
votes
Accepted
Making more than one instance of factory that is supposed to be singleton
Whatever kind of "clerical control" your application needs. If you don't know what that means, chances are high your application won't need such control ;-)
For example, this could mean to keep accou …