Borg Pattern Class usable from other classes?

Paul Winkler slinkp23 at yahoo.com
Fri Oct 12 16:19:58 EDT 2001


On Fri, 12 Oct 2001 10:27:23 +0200, Alex Martelli <aleax at aleax.it> wrote:
>Highlander for the DP, and Borg for the non-pattern which I
>posted and D. Ascher named, seem much more appropriate names,
>as the connection to science fiction movies/TV series is sharp
>and pleasingly anti-parallel.

AFAIKT, Borg is the same as Monostate which seems to have been around
for a couple years:

http://www.ddj.com/articles/1998/9809/9809a/9809as2.htm

At least, the Consequences are identical:
"""
    * Multiple local instantiations but always with only a single state.
    * Persistent object state in the absence of any instantiations.
    * Familiar syntax. Does not require an accessor function as with
      Singleton objects.  
"""

Borg is an OK name but Monostate is a little more obvious to those of
us who don't know much about Star Trek (yes, we exist).

BTW, are there any "gotchas" with Borg/Monostate in a multi-threaded
context? Singleton requires extra care, leading to the "Double-checked
Locking" pattern which apparently has been found not to work in
Java. Any such snags for Borg? I can't think of any, but I've only
really toyed with threads.

- Paul Winkler



More information about the Python-list mailing list