A code spike is a short, exploratory experiment for finding out whether a potential solution can work and how much effort it might take. Its goal is to make an unknown familiar enough to decide whether to continue or try another approach. section 3.0 section 3.1.1
Keep the experiment focused on learning:
- Probe the uncertain part, using sketches, temporary code, documentation, or small tests. section 3.1
- Treat the result as knowledge, not production code. Use what you learned to write production tests first, then implement a lean solution rather than copying the prototype. section 3.1.1 section 3.1.3
Learning Java regular expressions
To investigate parsing template variables, test Java’s regex API on “The needle shop sells needles.” A learning test can check that matching finds both occurrences and returns their start and end indices. Removing parentheses from the pattern and rerunning the test reveals whether those capture groups matter. The useful result is knowing how to locate the matches—not keeping the spike code. section 3.1.3
Listing 3.1. Making sure we can locate all matches within a given String
A compact learning test checks both match positions and that no further matches remain. section 3.1.3
