4 ms·
shrug. I've found singletons to be good for modelling session data in a web server. Calling GetInstance returns the object stored in the session, creating a ne
by statictype 15y ago
shrug. I've found singletons to be good for modelling session data in a web server.
Calling GetInstance returns the object stored in the session, creating a new empty one and stashing it there if required.
That's actually, pretty much the only thing I use them for, though.
- TwoSheds 15y agoIt's not really a singleton if it returns an instance per session instead of a global one.
- JonnieCache 15y agoYeah, its not really at true singleton in the dangerous sense in the context of a webserver, when you have a separate copy of the environment for each HTTP connection. It wouldn't be a singleton unless the same state could be accessed by different HTTP sessions. I haven't come across a web framework that enables this, as you might expect; there's no good reason to do so.
- misterbee 15y agoWhy don't you pass the session data as an argument to methods that need it?