Back to Glossary

Refactoring

Restructuring existing code to improve clarity, maintainability, or performance without changing its external behaviour.

Refactoring is the disciplined process of improving the internal structure of code without changing what it does. The tests pass before and after. The user sees no difference. But the codebase becomes easier to understand, modify, and extend.

Common refactoring moves: extracting repeated code into a function, renaming variables for clarity, splitting a large component into smaller pieces, simplifying conditional logic, and removing dead code. The goal is to pay down technical debt incrementally, not in one big rewrite.

AI is a powerful refactoring partner. You can select a block of code and say "refactor this to reduce duplication" or "split this into two components." Because refactoring has clear input/output (same behaviour, better structure), it is easy to verify the AI's work. Always commit before refactoring so you can revert if something breaks.

Related Courses

Links open the course details directly on the Courses page.