Singletons (was: Re: [squeak-dev] TheWorldMainDockingBar instance)

Hannes Hirzel hannes.hirzel at gmail.com
Sat Nov 6 07:00:43 UTC 2010


On 11/6/10, Levente Uzonyi <leves at elte.hu> wrote:
> On Sat, 6 Nov 2010, Hannes Hirzel wrote:
>
>> Hello
>>
>> The TheWorldMainDockingBar is implemented as a Singleton.
>>
>> To access the sole instance the method #instance is used. But we have
>> 35 implementor of #default and 20 implementors of #current for
>> implementing Singletons.
>
> There's also #soleInstance and probably a few more. Some people like this,
> others like that.
> Also some singletons are implemented with a class variable, others use
> class instance variables.
>
>>
>> Could somebody please change this the next time?
>
> You? :)

Thank you for the feedback.

I just tried to put the changed package Morphic into the inbox; but it
gives me a timeout with the current connection (GPRS/EDGE).

So what I did

a) added a class instance variable   'Default'
b) changed the the method #instance to #default and updated it
accordingly (in addition instead of 'super new'  just 'self new')
c) replaced the call to #instance with #default
d) removed method #instance
e) removed class variable   Instance


--Hannes

>
> Levente
>
>>
>> And TheWorldMainDockingBar is hard coded 5 places
>>
>> One thing we could do is to add the method
>>
>> mainDockingBarClass
>> 	^TheWorldMainDockingBar
>>
>> to MorphicProject
>>
>> and then replace the hard coded
>>
>> TheWorldMainDockingBar
>>
>> with
>>
>> MorphicProject current mainDockingBarClass
>>
>>
>> This is still hard coded but now offers the option that if I subclass
>> MorphicProject I can have another menu there.
>>
>> What do you think?
>>
>> Hannes
>>
>>
>
>



More information about the Squeak-dev mailing list