Singleton Pattern

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Singleton Pattern

Post by dejai »

Have you implemented the Singleton Pattern in your framework?
User avatar
Falco Girgis
Elysian Shadows Team
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:

Post by Falco Girgis »

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.
User avatar
Orgodemirk
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 784
Joined: Fri May 21, 2004 7:05 pm
Location: <pos>
Contact:

Post by Orgodemirk »

I use singletons in the framework for my perl scripts.
A glitch?
Image
User avatar
Falco Girgis
Elysian Shadows Team
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:

Post by Falco Girgis »

Peter, you also use singletons in lua.

:guffaw:
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Post by dejai »

nice :D
kilgariff
Chaos Rift Newbie
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?

Post by kilgariff »

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."
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Post by MarauderIIC »

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. =)
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
kilgariff
Chaos Rift Newbie
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:

Post by kilgariff »

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. =)
Effectively just a sugar-coated version of slinging a pointer 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."
Post Reply