GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

PNotificationCenter is a singleton but isn't declared as final #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Regardless of whether you think singleton's are evil, PNotificationCenter is 
one. It's constructor is private, it has an singleton accessor, and it even 
calls itself a singleton. 

It does not declare itself as final however so that anyone wishing to create 
multiple instances of it can do so easily by subclassing it.

This is another one of those binary incompatibilities I'd be game for since 
the clients it would break would be using it in a way that Piccolo clearly 
went out of its way to allow in the first place.

Thoughts?

Original issue reported on code.google.com by allain.lalonde on 13 Oct 2009 at 6:48

GoogleCodeExporter commented 9 years ago
I vote for pushing this to 2.0

Original comment by heue...@gmail.com on 21 Oct 2009 at 2:17

GoogleCodeExporter commented 9 years ago
Agreed, done.

Original comment by allain.lalonde on 21 Oct 2009 at 2:39

GoogleCodeExporter commented 9 years ago
Fixed in r1005.

Original comment by allain.lalonde on 16 Apr 2010 at 2:06

GoogleCodeExporter commented 9 years ago
Hi Allain,

what do you think about the following extension to your change:

// Your code
    public static PNotificationCenter defaultCenter() {
// My code to make it more threadsave ?
    public synchronized static PNotificationCenter defaultCenter() {
        if (DEFAULT_CENTER == null) {
            DEFAULT_CENTER = new PNotificationCenter();
        }
        return DEFAULT_CENTER;
    }

Original comment by tbit455...@aol.com on 17 Apr 2010 at 9:39

GoogleCodeExporter commented 9 years ago
Since it's a singleton, I think that's best practice. I will apply your 
suggestion.

Original comment by allain.lalonde on 17 Apr 2010 at 11:57

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 2 Mar 2011 at 4:12