Research on Singletons

Singletons are a concept I was not overly comfortable with. Singletons are creating a single referenced instance of a class/object to be referenced where needed in a program while avoiding duplicates. This is especially important for things like interfaces, which are used in a system to separate layers to allow for modularity. For instance, a graphics interface singleton would be set up on build to reference what it needs to use (DirectX, OpenGL, etc.) so that every other part of the program only needs to call the singleton to get something done, such as drawing an object.

Implementation wise, however, I’m still a bit rusty. I’ve been looking at different sources (previous course work from my school, msdn, etc.) and it seems straightforward. You make a class, make a static reference to that class which will be the instance, and give a public way for other classes to access it. I have some linker bugs that tend to pop up when I try this, though, as well as issues resolving a private static member.

 

For reference: http://silviuardelean.ro/2012/06/05/few-singleton-approaches/

https://en.wikipedia.org/wiki/Singleton_pattern

msdn, rastertek

Keywords: fsed3proj, singleton, msdn, silviuardelean.ro, rastertek, graphics, interface

Leave a comment