Singleton Pattern
Moderator: Coders of Rage
Singleton Pattern
Have you implemented the Singleton Pattern in your framework?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Yeah, MarauderIIC and I use singletons for almost every system in the engine.
Last edited by Falco Girgis on Sat Apr 19, 2008 1:51 am, edited 1 time in total.
- Orgodemirk
- Chaos Rift Devotee
- Posts: 784
- Joined: Fri May 21, 2004 7:05 pm
- Location: <pos>
- Contact:
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
-
- Chaos Rift Newbie
- Posts: 17
- Joined: Wed May 07, 2008 8:45 pm
- Current Project: ArkEngine, Regalia
- Favorite Gaming Platforms: PC (Linux, Windows)
- Programming Language of Choice: C++ and Assembly
- Location: Scotland
- Contact:
Bad practise?
I've heard a lot of people say that singletons aren't necessary, and the use of a singleton could be replaced, but I don't really know why someone would want to do so with no benefit to performance, clarity, or development time.
Carmack: "The most important thing is to try and learn things deeply. Don't try for a superficial knowledge of a lot of things. I've gotten where I am from knowing everything deeply, down to the lowest level."
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
-
- Chaos Rift Newbie
- Posts: 17
- Joined: Wed May 07, 2008 8:45 pm
- Current Project: ArkEngine, Regalia
- Favorite Gaming Platforms: PC (Linux, Windows)
- Programming Language of Choice: C++ and Assembly
- Location: Scotland
- Contact:
Effectively just a sugar-coated version of slinging a pointer around.MarauderIIC wrote:You can pass stuff around like a hot potato but it gets really complicated. Did you perhaps hear what to replace it with? I'm interested in any programming theory around. =)
The article and sub-article I read detailed everything that made singleton an "anti-pattern", but didn't suggest a better solution for that situation.
By the way, what do you use to implement singletons? I use a static instance that's initialized lazily. I'm going to thread my engine soon, and I don't think this is an *ideal* solution.
(PS. I tried to find the site that detailed everything wrong with the pattern, but I can't find it. If it's important, I could spend a little while retracing my steps.)
Carmack: "The most important thing is to try and learn things deeply. Don't try for a superficial knowledge of a lot of things. I've gotten where I am from knowing everything deeply, down to the lowest level."