The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,311 other followers

Canonical Delphi Singleton Pattern – Stack Overflow

Posted by jpluimers on 2017/11/29

Though I try to refrain from using the singleton pattern when possible (I prefer dependency injection over accessing “globals” that usually tend up to be not so global after all), sometimes I need to.

In C# there has been a canonical singleton pattern implementation by John Skeet for a very long time at [WayBackC# in Depth: Implementing the Singleton Pattern.

I just found out there has been similar implementations in Delphi both in this question (which like many useful questions is marked “closed”, oh the joy of StackOverflow): [WayBack] “Delphi Singleton Pattern – Stack Overflow:

I like both implmentation, but usually take the first as mostly locking has little overhead and sometimes two instances cannot co-exist (though that’s lessened when part of the singleton uses lazy initialisation, for instance from Spring4D).

–jeroen

via: [WayBack] May I please ask for your opinion on the following code:..singleton… – John Kouraklis – Google+

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: