| View previous topic :: View next topic |
| Author |
Message |
Ikopar Enthusiastic Coder
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)?
Reply with quote
|
| |
|
|
Jackil Enthusiastic Coder
Joined: 24 May 2006 Posts: 97
| |
froomzer Enthusiastic Coder
Joined: 23 May 2006 Posts: 148
| |
montanarry Enthusiastic Coder
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.
Reply with quote
|
| |
|
|
Klimapol Enthusiastic Coder
Joined: 27 May 2006 Posts: 134
|
Ikopar, singleton (mutable objects) suck. Immutable singleton; use enum.
Reply with quote
|
| |
|
|
Ikopar Enthusiastic Coder
Joined: 26 May 2006 Posts: 168
|
montanarry, I implemented the concrete class as private inner class in the abstract class.
Reply with quote
|
| |
|
|
montanarry Enthusiastic Coder
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.
Reply with quote
|
| |
|
|
Klimapol Enthusiastic Coder
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?
Reply with quote
|
| |
|
|
Ikopar Enthusiastic Coder
Joined: 26 May 2006 Posts: 168
| |
Jackil Enthusiastic Coder
Joined: 24 May 2006 Posts: 97
| |
| Page 1 of 2 |
Goto page 1, 2 Next |
|