This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In the JSF, I want to use service locator pattern, then I have two choices, one is use singleton + synchronizedMap, another choice is to inject a service locator instance in the DAO class . these two choices , what is pros and cons ?
There are some techniques to make a Singleton more unit testable. First you give it in interface. Then other classes can pass in a mock instead of the real Singleton. You can also change the static variable of the Singleton to another implementation of the interface, but that is hacky since it is global.