Chronos Manager Singleton

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Chronos Manager Singleton

Sean P. DeNigris
Administrator
Shouldn't the following be lazily initialized?

ChronosManager class>>#open
  ChronosInstance := self new.
  ^ChronosInstance

Right now the singleton gets wiped out every time "open" is clicked in the world menu, and one has to recustomize e.g. time and break limits...
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

kilon.alios
The initial intention was to not make it a singleton to allow for multiple instances of timers. Hence why it's wiped out. But making it a singleton is something Phil asked for too, I just forgot to turn it into a singleton. I will update it tomorrow. I use only a single instance myself as well too.
On Sun, 5 Feb 2017 at 02:02, Sean P. DeNigris <[hidden email]> wrote:
Shouldn't the following be lazily initialized?

ChronosManager class>>#open
  ChronosInstance := self new.
  ^ChronosInstance

Right now the singleton gets wiped out every time "open" is clicked in the
world menu, and one has to recustomize e.g. time and break limits...



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Chronos-Manager-Singleton-tp4933020.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

CyrilFerlicot
Le 05/02/2017 à 01:08, Dimitris Chloupis a écrit :
> The initial intention was to not make it a singleton to allow for
> multiple instances of timers. Hence why it's wiped out. But making it a
> singleton is something Phil asked for too, I just forgot to turn it into
> a singleton. I will update it tomorrow. I use only a single instance
> myself as well too.
>

If that's your intention why not keeping a "default" one and let the
user create new ones by hand?

Singleton is to prevent two objects to exist at the same time and if I
understood correctly there is nothing preventing to get two timer.

:)

--
Cyril Ferlicot

http://www.synectique.eu

2 rue Jacques Prévert 01,
59650 Villeneuve d'ascq France


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

Sean P. DeNigris
Administrator
In reply to this post by kilon.alios
kilon.alios wrote
The initial intention was to not make it a singleton to allow for multiple
instances of timers.
I could see some use cases there. My intention was just not to have to set time/break limits on every open. Another option would be to lazily initialize those defaults into class vars instead of hardcoding...
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

kilon.alios
In reply to this post by CyrilFerlicot
The idea was to use this as a fail safe in case you lost the reference to your instance.

Singleton does not prevent you to have two or more instances existing at the same time cause this is standard behavior for OOP. What it does is making sure that it avoid unintentional creation of instances.

Maybe I did not make myself clear but my intention was to create multiple instances of ChronosManager , NOT prevent this.

On Sun, Feb 5, 2017 at 2:33 AM Cyril Ferlicot D. <[hidden email]> wrote:
Le 05/02/2017 à 01:08, Dimitris Chloupis a écrit :
> The initial intention was to not make it a singleton to allow for
> multiple instances of timers. Hence why it's wiped out. But making it a
> singleton is something Phil asked for too, I just forgot to turn it into
> a singleton. I will update it tomorrow. I use only a single instance
> myself as well too.
>

If that's your intention why not keeping a "default" one and let the
user create new ones by hand?

Singleton is to prevent two objects to exist at the same time and if I
understood correctly there is nothing preventing to get two timer.

:)

--
Cyril Ferlicot

http://www.synectique.eu

2 rue Jacques Prévert 01,
59650 Villeneuve d'ascq France

Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

kilon.alios
In reply to this post by Sean P. DeNigris


I could see some use cases there. My intention was just not to have to set
time/break limits on every open. Another option would be to lazily
initialize those defaults into class vars instead of hardcoding...


Well my intention also was to provide a way to save preset settings and default settings to external files but again I was distracted by other projects and did not bother implementing this.

Also in process I decided that I did not like the idea of multiple ChronosManagers GUIs to exist, instead I decided to use one GUI to handle multiple timers.

This is why I also chose to go down the singleton route , but I gain it fall down the list of priorities because I was busy making CPP .

I will be working today to improve ChronosManage, implement the singleton and optimize the loading of its assets because it seems to do some unecessary loading and maybe implement a feature or two. I will keep you posted :)
 
Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

Ben Coman
In reply to this post by CyrilFerlicot
On Sun, Feb 5, 2017 at 8:32 AM, Cyril Ferlicot D.
<[hidden email]> wrote:

> Le 05/02/2017 à 01:08, Dimitris Chloupis a écrit :
>> The initial intention was to not make it a singleton to allow for
>> multiple instances of timers. Hence why it's wiped out. But making it a
>> singleton is something Phil asked for too, I just forgot to turn it into
>> a singleton. I will update it tomorrow. I use only a single instance
>> myself as well too.
>>
>
> If that's your intention why not keeping a "default" one and let the
> user create new ones by hand?
>
> Singleton is to prevent two objects to exist at the same time and if I
> understood correctly there is nothing preventing to get two timer.


I never paid much attention to the semantics of different singleton.
But recently I read this and found it made sense...
https://www.peteruhnak.com/blog/2015/12/06/singleton-variations/

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: Chronos Manager Singleton

kilon.alios
Very interesting read Ben thanks for sharing

By the way I added the singleton and I optimised the loading of some image files. More optimizations will follow the next weeks. So now you should not be annoyed with multiple instances of ChronosManager

Thank you all for your interest in ChronosManager :)

On Sun, Feb 5, 2017 at 3:17 PM Ben Coman <[hidden email]> wrote:
On Sun, Feb 5, 2017 at 8:32 AM, Cyril Ferlicot D.
<[hidden email]> wrote:
> Le 05/02/2017 à 01:08, Dimitris Chloupis a écrit :
>> The initial intention was to not make it a singleton to allow for
>> multiple instances of timers. Hence why it's wiped out. But making it a
>> singleton is something Phil asked for too, I just forgot to turn it into
>> a singleton. I will update it tomorrow. I use only a single instance
>> myself as well too.
>>
>
> If that's your intention why not keeping a "default" one and let the
> user create new ones by hand?
>
> Singleton is to prevent two objects to exist at the same time and if I
> understood correctly there is nothing preventing to get two timer.


I never paid much attention to the semantics of different singleton.
But recently I read this and found it made sense...
https://www.peteruhnak.com/blog/2015/12/06/singleton-variations/

cheers -ben