Re: Is Apple's singleton sample code correct?
Re: Is Apple's singleton sample code correct?
- Subject: Re: Is Apple's singleton sample code correct?
- From: David Gimeno Gost <email@hidden>
- Date: Thu, 1 Dec 2005 22:23:42 +0100
On 1 Dec 2005, at 18:46, glenn andreas wrote:
Then don't use singletons.
Looking through the GOF "Design Patterns" under "Singletons", it's all
about "ensure a class has only one instance, and provide a global
point of access to it." There is absolutely nothing in the singleton
pattern that deals with cleanup, deallocation, etc,
That's exactly my point. Your choice of using a singleton or not should
*only* have to take into account whether at most one instance of it can
exist at any time and whether providing a global access point makes its
use more convenient. You shouldn't be prevented from using it because
of dependency issues. You should be able to handle such issues as you
would for any other object. I don't understand why using the right
argument leads you to the wrong conclusion.
and, in fact, in the canonical C++ implementation of Singleton in
said book (p 129) does not have a destructor, because it isn't ever
deleted.
This is not the canonical C++ implementation. Actually, nobody uses
that implementation in C++ precisely because of the lack of a
destructor:
http://groups.google.com/groups?
as_q=&num=10&scoring=r&hl=en&as_epq=&as_oq=&as_eq=&as_ugroup=comp.lang.c
++.moderated&as_usubject=singleton&as_uauthors=&lr=&as_qdr=&as_mind=
1&as_minm=1&as_miny=1981&as_maxd=1&as_maxm=12&as_maxy=2005&safe=off
e.g. the thread titled "GoF Singleton C++ implementation":
http://groups.google.com/group/comp.object/browse_frm/thread/
8227731a5906922d/4bc76d3b1740de6f?
tvc=1&q=group:comp.lang.c++.moderated+insubject:singleton&hl=en#
4bc76d3b1740de6f
Regards.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden