One can always find ways of writing clean code in an iterative manner.
When writing new code, the process usually involves something like:
- Write some code which ‘works’
- Run some test cases
- Go back and clean up the code
- Rerun the tests
- Further clean up the code
- Etc etc