Recipe 08 / Useful leftovers

Keep what is worth using again.

A finished recipe often leaves behind a helpful script, a test, or a clarified assumption. Preserve those pieces deliberately so the next task can start from evidence.

Result: A maintainable project utilityGo to method
  1. Package the working example

    Keep the smallest fixture and its expected result beside the script or test. Document the command, tested runtime, and any deliberate limits, such as loading the entire CSV into memory. Remove private data from retained examples. Save the reasoning behind a conversion rule; a future reader can infer the mechanics from the code.

  2. Wait for a second use

    When another real task needs the same behavior, compare its requirements with the first. Extract the shared function only when the overlap is clear. Keep file loading, transformation, and presentation separate where that reduces actual duplication. Avoid turning one successful script into a configurable framework before another user or workflow requires it.

  3. Recheck the new serving

    Run the original fixture after adapting the tool and add a representative example for the new use. Check that errors remain readable and existing callers still behave as expected. Archive experiments that are no longer useful instead of leaving several nearly identical scripts without an obvious owner. A reusable tool needs a maintained contract, not just a memorable filename.

The serving check

The original recipe still works, the new use has a check, and the retained tool has one clear responsibility.

A brief for your assistant

Compare these two scripts and their expected outputs. Identify genuinely shared behavior and differences that must stay explicit. Propose the smallest reusable function and checks before changing either script.

At the workspace

Reference documentation view. Keep recipe commands and assumptions with your own project as well. Reference desktop preview; final product screens may differ.
Next at the counterRecipe index