4 attributes of scary code: 🚩 Feels needlessly complex 🚩 Unclear intent 🚩...


4 attributes of scary code:

🚩 Feels needlessly complex
🚩 Unclear intent
🚩 No tests
🚩 Buggy

😬

This is a scary combo. It often means we're hesitant to touch it.

Whoever does takes a big risk.

Solution:
1. Create tests to cover the current working behavior.

2. Write a test that fails due to the buggy behavior.

3. Now that we have tests, we can safely refactor to improve clarity. Decompose the code if necessary to improve the feedback loop and to isolate the buggy section.

4. Now the code should be easier to understand, and the buggy section of code should be identified and isolated. Make the test pass.

View original on X