The singleton design pattern in D, C++ and Java

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Aug 3 07:34:19 PDT 2010


On 16/07/2010 18:18, Ali Çehreli wrote:
> Justin Johansson wrote:
>> Which language out of C++, D and Java does this classical
>> "GoF" (gang-of-four***) design pattern best?
>
> Are we still talking singleton? I thought that it is considered an
> anti-pattern already. :)
>

First time I've heard this as well. I searched the web, and woah, there 
does seem to be quite a few people who think the same, but frankly, upon 
reading their arguments against singleton (in the sense that singleton 
should not be used), most of them don't add up. In fact some of those 
arguments are quite idiotic, a lot of people are totally 
misunderstanding singleton.
(im not going to botter arguing why, and I hope people here don't think 
singleton is inherently bad)
Cause man, I haven't seen such idiocy since when I joined a new company 
and found the then lead developer enforced a policy in our Java codebase 
of single return statements. Because multiple return statements were 
very bad and should *only* be used if performance necessitated that. 
Lolz. Talk about software engineering best practices from the 60's.

-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list