I'm a bit skeptical of that as a general principle.
I want code to be a consistent representation of my mental model of the solution at all times. I use code to help me think, remind me of my thinking and communicate with others. It's not just a series of commands that make a machine do something.
As long as any ugliness is not in conflict with this purpose it's fine. I can totally live with functions that are a bit messy and probably need cleaning up later.
1) Make it work 2) Make it maintainable 3) Make it fast
All three should be on your mind when developing something, but if you have to choose between 2 and 1, go with 1.
My rule is simpler: never write instant legacy code. If it feels like something you won't understand a month later, it likely is legacy code.
If it reads badly (and I'm not talking about this or that brace or whitespace choice), then it also provably is in that category.
(On C2 wiki, a proper SpikeSolution)
If you hit a case your design cannot cleanly handle, it is time for redesign, but often a tiny amount of design constrained by use cases will expose a good design quickly.
Why can't you just keep working until you consider your task done?
Development time is inherently very hard to predict, so strict deadlines - even if set by people who understand the technical issues don't make a lot of sense. There many books on this, and I won't try to summarize them here.
Still, if you have a deadline, you can use your time however you want before the deadline, right? So if it's better/faster to clean up the code after you made it work than to try to type everything perfectly the first time, what's stopping you?
Or is it that the deadlines are so tight that you only have time to write terrible code?
But when I see developers with the self-expectation of clean code take on a task where the architecture is not self-evident, where the architecture probably won't be right the first time, then they often freeze up. Or they move their efforts into the abstractions they do understand, instead of the task they are trying to accomplish.
I'm talking about one single commit.
If I spend 4 hours on a story, the last half hour is probably spent cleaning up things. That's when it's easiest to do, because now that the problem is solved, I understand things the best, and the code is not in flux.
I do not have to ask a manager for permission to do this. If you do, you should really try to find a job where you're trusted to make these simple technical decisions.
If the code is working but is badly designed, that can take longer.
Occasionally, the new feature requires larger refactorings to redesign preexisting code. That can take days, but is of course essential to do.
Adhering just somewhat to principles from the beginning shouldn't make this too time consuming.
1. That's a good way to break it.
2. Typically there is not extra time given to cleanup code, write docs and unit tests.
That is: Make it pretty and readable and DRY once the code works. Until then my code can have several ugly and improvised things I've left for later.