
google-singleton-detector
Google Singleton Detector
Building GSD | Running GSD | Known Limitations | FAQ
The Google Singleton Detector, or GSD, is a tool which analyzes Java bytecode and detects the use of Singletons.
It's not quite as simple as that, however. First, GSD doesn't only detect singletons; it detects four different types of global state, including singletons, hingletons, mingletons and fingletons (see the usage section for descriptions). Second, it outputs a graph with all these different types of static state highlighted, and shows all the classes that are directly dependent on them. The point of this tool is to allow you to see all of the uses of global state inside a project, as well as how they are all interrelated. Hopefully you'll be able to locate global state that is heavily depended on and remove it.
But wait, why would I want to remove my global state and/or singletons? In a nutshell, because they can make testing difficult and hide problems with your design. Again, it's more complicated than that, so check out the FAQ for more info.
Great, ready to get rid of some singletons? Head over to the downloads section to get the latest release, or checkout code from the SVN repository and build it yourself.
Keep in mind this is still an early build; if you find that some classes are not being labeled properly, check the known limitations and file an issue if appropriate.
Where to next?
GSD was build in order to help identify hard to test code which is due to singletons design pattern. We now have a general form of "Testability" available here at Testability Explorer. You can see a demo of Testability Explorer at http://www.testabilityexplorer.org/.