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

Nick Sabalausky a at a.a
Fri Jul 16 11:21:28 PDT 2010


"Ali Çehreli" <acehreli at yahoo.com> wrote in message 
news:i1q4bk$21jp$1 at digitalmars.com...
> 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. :)
>
> As a teaser: What problem does it solve that can't be solved by creating 
> just one object of a type?
>

In languages that don't allow functions outside a class, they're useful as a 
make-shift substitute for a module with free-floating functions. Or at least 
if you count static classes as a form of singleton, anyway.




More information about the Digitalmars-d mailing list