I\'m making a program in Java with the Observer pattern (with the help of the Java API). If some of the observables had more than one instance, the program could crash. Should I
Should I implement them as singleton? Is it recommended?
Of course you can do this. Whether it is a good idea depends on the actual context.
Are these things conceptually singleton, or is this just a hack to try to make bugs disappear? (Or to put it another way, is the real problem that your application design is wrong ...)
Singletons do have issues with respect to unit testing. This is not a show stopper, but it is one of the reasons that people tend to avoid them.