The singleton design pattern in D, C++ and Java
foo at bar.com
Thu Aug 5 04:02:39 PDT 2010
"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message
news:i39d0s$2596$1 at digitalmars.com...
> Bruno Medeiros wrote:
>> 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
>> (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.
Having a single point of exit from a function is still a design practice in
the Joint Strike Fighter (JSF) C++ Coding Standard (Rule 113) and is a
requirement in MISRA C++:2008 (Rule 6-6-5) and MISRA C:2004 (Rule 14.4) and
also a requirement to writing software under IEC61508 (Part 3, Table B.9).
So its still an engineering best practice in the 10's :-)
More information about the Digitalmars-d