Level 1 · Apprentice0 XP
One instance is fine. Global access to it is the problem.
Step 1 / 5
ProblemAny class can reach the configuration, the database and the clock through a static call. Nothing in a constructor tells you what a class needs. A test cannot replace the database, and tests affect each other through shared state.
← → step
Before this: Abstract Factory and Prototype
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Find a class that calls a static getInstance() or a global object with state. Pass that dependency through the constructor instead, and write a test that gives it a fake. Note what the constructor now tells you that it did not before.