It is still the same thing and works exactly the same. You just tidied up the inside.
Like re-planning the paths in a restaurant kitchen: not one word of the menu changes and guests get the same dishes, but the cooks walk half as far.
2
How is it different from what you'd expect?
NEW FEATURE
Change the menu
Guests can taste the difference: a new dish, or an old dish that now tastes different.
REFACTORING
Change the kitchen flow
Guests notice nothing. What changes is where cooks stand, where things are kept, and who can reach what.
Put simply: refactoring is nothing changed outside, everything changed inside. There is one test for whether it was done right: people outside can't tell.
3
Why tidy up at all?
Because things get messier on their own if you don't.
At first, adding one thing takes an hour. After two years of cramming, the same small job means digging around for ages to find where to touch, and then worrying you'll knock something else over. Now it takes a day.
The mess itself isn't the disaster. The disaster is that every small job from now on gets more expensive.
That is why sometimes a week passes and you see nothing new. That week went into straightening the road so the next ten jobs go faster.
4
How to tidy up without breaking things
1. Write the checklist firstBefore touching anything, write down "what counts as not broken", and make the check re-runnable with one click.
2. Move one thing at a timeNo tearing it all down at once. Move one small thing, that is one step.
3. Re-check after every stepRight after moving, run the checklist. Only when it is all green do you take the next step.
4. Red? Step backDon't force a fix. Going back one step and redoing it is ten times cheaper than patching a mess.
All four steps mean one thing: catch every "oops, I broke it" on the spot, instead of letting a customer find it for you three months later.
5
What exactly gets tidied?
Same text copied five timesKeep one copy and let all five places use it. Next time you change it once.
Names nobody can readRename "a1" to "dish the guest ordered", so even you in six months can tell
One big jumbleOne tool doing eight jobs gets split into eight tools, one job each
A roundabout routeSeven turns before, now a straight line
Old stuff nobody usesDead but still kept, taking space and blocking the view. Remove it.
Mysteriously slowSomething recalculated every time gets calculated once and remembered
6
One thing it doesn't do
While tidying, don't slip in new thingsAnd don't fix other problems on the side. This is on purpose. Mix them, and when something breaks you can't tell whether the tidying or the new thing did it, so you have to dig through both. Do them separately and you see at a glance who to blame.
Same logic: if you want a new feature, tidy first, then add it. Don't move the tables while you're cooking.
"It feels like nothing got done this week?"
Sometimes it really was nothing. Sometimes it was straightening, in one go, the road you will walk every day for the next three months.
Refactoring doesn't produce anything you can see today. It produces the ability to keep every future job fast. Never tidy, and eventually things don't just get slower, they get stuck. By then, if you ask for one small feature, the answer is "that needs a rebuild".