
Software Design – The Singleton Pattern
The last of the creation patterns we will cover is the Singleton. This is a pattern that has a little controversy around it and may even be an anti-pattern. It is easy to implement, but the reason for needing one can trip you up. The Singleton Pattern Defined It helps to start with the “Gang of Four” definition and then we will dig into that. “Ensure a class only has one instance, and provide a global point of access to it.” This is what we use when we need one and only one instance. An example might be the application settings or an instance that represents a real-world device (keyboard, mouse, maybe even a printer or hard drive). When we access values... Read more