refactoring

Restructuring working code to make it clearer or easier to change without changing what it does.

In more detail

Refactoring improves names, splits long functions and removes duplication while behaviour stays the same. Tests make it safe, because they show at once if behaviour changed.

Examples

The course refactors a monolithic alert with boolean props into composable subcomponents; visual tests confirm nothing changed on screen.
In the browser: In the course you refactor a loop that mixes DOM reads and writes into one that batches them, keeping the result identical but avoiding layout thrashing.
Explicit generic types let Java tools refactor code automatically.
The course refactors its mad lib program into small functions such as getKeys and tellStory.
Many course exercises are refactors: moving a hook out of a condition, replacing an Effect with a derived value or turning a render prop into a custom hook.

Related terms

Taught in

References

Certification courses