Level 1 · Apprentice0 XP
The order of steps is fixed. Some of the steps are left to subclasses, or to functions you pass in.
Step 1 / 5
ProblemThe CSV, JSON and XML importers each open a file, parse it, validate, save and close. The outline is copied three times. A fix to the error handling has to be made in three places, and one is forgotten.
← → step
Before this: State: a lifecycle without the if-jungle
🛠️ 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.Write a function retrying(times) { block } that runs a block, retries on exception up to N times with a pause, and rethrows the last error. The loop is the fixed part, the block is the varying step. Use it for two different operations.