View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Help with singleton design pattern

From: Artur Trzewik <mail_at_xdobry.de>
Date: Tue, 22 Apr 2003 21:21:13 +0200

Hallo!

As singleton objects I often use Objects directly derived from Object

Object MySingleton
MySingleton proc doJob {} {
   puts "This is my job"
}

MySingleton doJob

This is not singleton pattern but is same cases you do not need some
Java, C++ solution.
One disadvantage is that you can not use method inheritance.

By the way.
The presented solution from G. Neumann.
That is to overwrite "new" method that returns singleton object
is the standard way to implements singleton in Smalltalk
(the singleton instance is saved in class variable Default).
That is XOTcl! "new" is just method not special operator and can
be overwritten.

Artur Trzewik