| View previous topic :: View next topic |
| Author |
Message |
Ikopar
Joined: 26 May 2006 Posts: 168
|
| I try to implement a singleton pattern: Therefore I have an abstract class with a static field "singelton" and an appropriate getter. Does updating of "singleton" work without a real instance of the class (as it is abstract)? |
| |
|
|
|
|
Jackil
Joined: 24 May 2006 Posts: 97
|
| Ikopar, wtf |
| |
|
|
froomzer
Joined: 23 May 2006 Posts: 148
| |
montanarry
Joined: 13 May 2006 Posts: 175
|
Yes and no. You can access the object via the abstract interface, but you can't construct an instance without a concrete class.
You need a concrete class, that is. |
| |
|
|
Klimapol
Joined: 27 May 2006 Posts: 134
|
| Ikopar, singleton (mutable objects) suck. Immutable singleton; use enum. |
| |
|
|
Ikopar
Joined: 26 May 2006 Posts: 168
|
| montanarry, I implemented the concrete class as private inner class in the abstract class. |
| |
|
|
montanarry
Joined: 13 May 2006 Posts: 175
|
Ikopar, and the nice thing about know something is you can always be wrong.
Yu can do what you asked. Be careful.
Ikopar, The short answer to your question was yes, not no. |
| |
|
|
Klimapol
Joined: 27 May 2006 Posts: 134
|
Ikopar, whatever you do with a singleton boils down to one or two cases.
Is it mutable? Yes or no? |
| |
|
|
Ikopar
Joined: 26 May 2006 Posts: 168
|
| Klimapol, nope it isn't by the interface provided. |
| |
|
|
Jackil
Joined: 24 May 2006 Posts: 97
|
| Mutable singletons are asking for trouble |
| |
|
|
| Page 1 of 2 |
Goto page 1, 2 Next |
|