Scala gives you all sorts of possibilities for testing Singletons, but
if you control the code-base the best bet is to avoid traditional Gang
of Four singletons entirely. I would recommend looking at dependency
injection as an alternative - something like Guice or the cake pattern
demoed by Martin Odersky (personally I use Guice because of
familiarity and also I find it slightly more powerful). Using DI will
let you have an easy to test codebase and still control everything
about the unit testing of the classes, and you can still effectively
have singletons (the @Singleton annotation in Guice) without paying
the cost of that hard-wiring.
Scala objects are useful for a bunch of other things too though, for
example companion objects, case objects, etc. so I don't believe a
general rule about avoiding them is a good idea.
--
Dick Wall
Email:
di...@bldc.org Gmail:
dick...@gmail.com Skype: dickwall
AIM: QuaintRcky
Co-Host of the Java Posse:
http://javaposse.com Blog:
http://dickwallsblog.blogspot.com