Re: Best practices with singletons

2014-06-10 Thread Dave
Hi, You should take a look at this article: http://c2.com/cgi/wiki?SingletonsAreEvil Cheers Dave On 8 Jun 2014, at 17:30, William Squires wrote: > Okay, I have several classes in my (somewhat large, and growing) project > that implement the singleton pattern via a [ shared] > class method

Re: Best practices with singletons

2014-06-09 Thread Glenn L. Austin
On Jun 8, 2014, at 9:30 AM, William Squires wrote: > Okay, I have several classes in my (somewhat large, and growing) project > that implement the singleton pattern via a [ shared] > class method (and a file-scope static reference) that uses lazy loading to > instantiate the singleton the fir

Re: Best practices with singletons

2014-06-08 Thread Graham Cox
On 9 Jun 2014, at 2:30 am, William Squires wrote: > uses lazy loading to instantiate the singleton the first time a reference is > asked for. Sounds good. > Is it considered better to put all of these calls in the main() function > before any other code executes, Huh? > or not worry about

Re: Best practices with singletons

2014-06-08 Thread Seth Willits
The practical answer in short is: Just always access through +sharedInstance, no need to pre-initialize, and only use it on the main thread. This is one of those threads that will easily become a stupidly long debate that's been had a dozen times before. If you're interested in all of the intr

Re: Best practices with singletons

2014-06-08 Thread Jens Alfke
On Jun 8, 2014, at 9:30 AM, William Squires wrote: > Is it considered better to put all of these calls in the main() function > before any other code executes, or not worry about it, and just access them > through the above class methods when and where needed? I wouldn’t recommend early initi

Best practices with singletons

2014-06-08 Thread William Squires
Okay, I have several classes in my (somewhat large, and growing) project that implement the singleton pattern via a [ shared] class method (and a file-scope static reference) that uses lazy loading to instantiate the singleton the first time a reference is asked for. Is it considered better t