Skip to content

Use small and isolated experiments to resolve uncertainties

When facing uncertainties, create focused experiments to get definitive answers rather than making assumptions or proceeding with incomplete knowledge.

Small and isolated experiments offer:

  • Fast feedback - get answers in seconds or minutes, not hours
  • Low risk - test ideas without affecting production code
  • Clear insights - isolate variables to understand exactly what’s happening
  • Reduced friction - avoid long build times and complex setup

Without feedback, there is no opportunity to learn. We can only guess, rather than make decisions based on reality. - Dave Farley in Modern Software Engineering

  • Minimal test programs - Single-file .cpp programs for isolated testing
  • Unit test sandboxes - Small test cases in your test framework
  • Interactive debugger - Step through code to understand behavior
  • REPL environments - For languages/scenarios that support them

Common uncertainties and experimental approaches

Section titled “Common uncertainties and experimental approaches”

“Will this optimization actually help?”

  • Test on Quickbench

“Will this template work across compilers?”

  • Test on Compiler Explorer with multiple compilers
  • Verify template instantiation with C++ Insights
  • Check assembly output for optimization assumptions

“Does this regex match what I expect?”

  • Validate patterns interactively on Regex101
  • Test edge cases before integrating into code

“How does this function behave with empty input?”

#include <gtest/gtest.h>
#include <vector>
TEST(SuspiciousFunctionExperiment, CheckWhatHappensWhenInputIsEmpty) {
std::vector<int> empty;
auto result = suspicious_function(empty);
EXPECT_EQ(result, "");
// If the result is not "", the output log will show the actual result.
}

Unit tests are particularly valuable when:

  • Working with proprietary or sensitive code that cannot be shared online
  • Needing to preserve experimental insights in your test suite

Using LLM/AI for experimentation can also be very effective:

  • Show some code to the AI and ask it: how would this code look
    • … if functional oriented?
    • … using modern C++ idioms?
    • … with RAII principles?
  • Show me 3 different ways to …, and then review which one is cleaner

This approach works best when you:

  • Have specific technical questions that can be tested
  • Want to validate assumptions before committing to an approach
  • Need to understand behavior in isolation from your larger codebase
  • Face long build times that make iteration expensive in your main project

For complex architectural decisions or broader design questions, other approaches like prototyping or design reviews may be more appropriate.

  • Isolate one variable - test only the specific uncertainty
  • Use minimal setup - avoid unnecessary complexity
  • Document findings - capture insights for future reference
  • Iterate quickly - prefer fast feedback loops over comprehensive tests