Practice workspaceY
Learning path
LEVEL 7 · TESTING & REFACTORING

Preserve behavior while refactoring

Name and verify invariants before changing structure.

01 / PREDICT

Which observations should stay the same after extracting a function?

02 / EXPLAIN

The judgment behind the action

Characterization tests capture existing behavior. Decide which behaviors are intentional before preserving them. Keep structural changes separate from behavior changes where practical, and review callers and edge cases. A refactor should not smuggle in new requirements.

03 / DEMONSTRATE

A bounded way to ask

Extract the existing filter function without changing empty-query results, matching semantics, order, or mutation behavior.
04 / PRACTICE

List invariants for a filter utility extraction.

Which observations should stay the same after extracting a function?

Choose the best next action

Guided practice contributes completion, not independent mastery.

06 / REFLECT

Make the lesson yours.

Your reflection is attached when you submit your decision. Drafts remain in this tab.

07 / TRANSFER

Try it somewhere unfamiliar.

Apply this skill to an unfamiliar repository: list invariants for a filter utility extraction. Record the evidence you would need.

Choose your next practice
Source checked 2026-09-09 · Documentation profile · Runtime example untestedOfficial reference