Okay...I have a situation where a C# .dll is a singleton. Now, what I want to be able to do is when the singletonInstance is instantiated be able to provide a reference to any other applications that may start. So, I looked up NamedPipes and that would work - except for one thing, this must be cross-platform, or platform independent. I h...
Hi all,
This is in response to some comments in what is so bad about singletons
There it was suggested that the proxy pattern can be used instead of a singleton to cache DB data. But I cannot see the advantage, and in fact the singleton seems more "controllable".
Let me elaborate on the problem. Assume you have a database, with a la...
In PHP if I create a singleton method for like 5 different caching classes (memcache, apc, session, file, cookie)
Then I have a main cache class which basicly routes my set() and get() methods to the appropriate caching class. Now lets say I need to use the session, cookie, memcache, and file cache all on the same page. My main cache ...
I've had some experience developing for the iPhone but am entirely self taught and am trying to improve my practices. This is a question that is probably pretty introductory to programming.
What is the best way (or is it possible) to maintain instance variables with values that are common to all instances of an object? Is it possible to...
Hi,
Is the singleton requirement of a provider is a performance hit ?
Because all the database read/write opertions must be taking place through that singleton. Wouldnt it be an issue with multiple users doing read/write operation in a site like Blogger.
...
I am working with PHP classes and objects now. In this question the names of fields and methods are made up just so you get an idea of what I am talking about.
It is related to using the singleton and registry design patterns.
Now lets say I need to access a Database object, Cache Object, Core Settings object, Session object in al...
I have asked a few question lately about the use of the singleton and registry patterns but here is a new question I have.
Let's say I have 3 main class object in PHP that I need to have access to inside 20 other class files and sitewide.
Database object
Cache object
Core object
I then can use a Registry pattern to store all...
Assume, I have the following class:
class MyClass
attr_accessor :vars
def initialize
@vars = []
end
def add_var var
@vars << var
end
end
I want to access inners vars like this:
x = MyClass.new('root')
x.add_var 'test'
x.add_var 'something'
x.add_var Myclass.new('google')
x.google.add_var 'nice'
puts x.test
puts ...
Just i was thinking about the other ways of writing singleton class. So is this class considered as a singleton class?
public class MyClass{
static Myclass myclass;
static { myclass = new MyClass();}
private MyClass(){}
public static MyClass getInstance()
{
...
I recently found out about auto-properties and like them quite a lot. At this moment I am trying to use them everywhere where I can. Not really to just be able to use them everywhere, but more to see how well they work in most situations.
Now I am making a singleton and thought:"Hey, let's try auto-properties here as well".
public cla...
Possible Duplicate:
Advantage of Static class over use of Singleton
Usually, everytime I needed a single systemwide object I used the singleton pattern.
M question is, why shouldn't i just implement the object as static and get the single object behaviour naturally ? Are there any cons to use static types over singleton factore...
Not even sure if module-level is correct here, but...
I have a Pylons project and within the model component I have a global variable, doc, in __init__.py that I want to use from different Query objects. (doc is a Document handle on an XML file that I am using as a fake DB.) My question is, when does __init__.py's scope end? Currently I...
Hello,
I'm trying to implement this singleton class. But I encountered this error:
'Singleton::~Singleton': cannot access private member declared in class 'Singleton'
This is flagged in the header file, the last line which contains the closing brace.
Can somebody help me explain what is causing this problem?
Below is my source code.
...
Hello,
Just want to make sure I am not assuming something foolish here, when implementing the singleton pattern in an ASP .Net web application the static variable scope is only for the current user session, right? If a second user is accessing the site it is a different memory scope...?
Thanks
...
I am currently working on an application in C# that runs on an infinite loop with a Thread.Sleep call after each iteration of the other method calls. My main is -
static void Main(string[] args)
{
bool isOnlyInstance = false;
Mutex mutex = new Mutex(true, "RiskMetricsSensitivitiesDatabaseLoader", out isOnlyInstance...
When I hit the run button (in my Default.aspx), a process starts (this process contacts a webservice to get some files, etc). How do I:
Ensure that only a single process is running at a time (i.e. if I refresh the browser, I don't want to start the process a second time)
Track progress - there are 4 points of the process (at 25%, 50%,...
Hi,
I'm currently trying to implement a factory as a singleton. I practically used the textbook example of the Singleton pattern. Here's the .h file:
namespace oxygen{
class ImpFactory{
public:
static boost::shared_ptr<ImpFactory> GetInstance();
private:
static boost::shared_ptr<ImpFactory> mInstance;
};
and here's the .cp...
Pretty straight forward question.
What is a Singleton and when should I use it?
...
here is code
+ (SalesCollection*)sharedCollection {
@synchronized(self) {
if (sharedInstance == nil) {
[[self alloc] init]; // assignment not done here
}
}
return sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone {
@synchronized(self) {
if (sharedInstance == nil) {
sharedInstance = [super allocWithZone:z...
how do i (and does it makes any sense?) inherit from the singleton class other classes that need the same functionality?
...