Code Room
Vibe codingHard
Question
You asked an AI to write a thread-safe lazy singleton cache initializer in Java. It produced this double-checked-locking variant and assured you it's the canonical pattern. Review it.
public class ConfigCache { private static ConfigCache instance; private final Map<String, String> data; private ConfigCache() { this.data = loadFromDisk(); } public static ConfigCache getInstance() { if (instance == null) { synchronized (ConfigCache.class) { if (instance == null) { instance = new ConfigCache(); } } } return instance; }}It mostly works. Under what conditions does a thread see a broken object, and what's the fix?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.