Imagine you need a lookup cache for something.
I know this implementation is wrong. For one thing, you cannot mock it for unit tests.
But I know there must be other reasons it is bad.
public class FooCache {
private static Map<String, String> cache = new HashMap<>();
public static populate(...) {
...
}
public static String getWhositForWhatsit(String whatsit) {
return cache.get(whatsit);
}
Aucun commentaire:
Enregistrer un commentaire