Re: Ada-Singleton-Why does it work like this?
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Tue, 24 Mar 2009 22:21:03 +0100
On Tue, 24 Mar 2009 12:01:00 -0700 (PDT), patrick.gunia@xxxxxxxxxxxxxx
wrote:
I´m currently working on implementing several design patterns in Ada,
and I found some code concerning the Singleton-pattern when searching
through the posts of this group.
A side note. Singleton is not needed in Ada. Arguably the only valid use of
singleton is execution of some piece of code once upon elaboration of some
module. In Ada this is achieved by putting elaboration code put in the body
of corresponding package:
package body Foo is
... -- Implementation of the entities declared in Foo
begin
... -- Elaboration code, executed once
end Foo;
A related, though a bit suspicious use of singleton is when it encapsulates
a managed global state is achieved again by a package. See the post of
Jeffrey Carter that illustrates this case.
The bottom lime. Singleton pattern is used only in the languages which bind
visibility to type. In Ada visibility is bound directly to the module
(package), which eliminates any need in this pattern.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Ada-Singleton-Why does it work like this?
- From: patrick.gunia@xxxxxxxxxxxxxx
- Re: Ada-Singleton-Why does it work like this?
- References:
- Ada-Singleton-Why does it work like this?
- From: patrick.gunia@xxxxxxxxxxxxxx
- Ada-Singleton-Why does it work like this?
- Prev by Date: Re: Ada-Singleton-Why does it work like this?
- Next by Date: Re: Ada Lovelace Day
- Previous by thread: Re: Ada-Singleton-Why does it work like this?
- Next by thread: Re: Ada-Singleton-Why does it work like this?
- Index(es):
Relevant Pages
|