Working code is better than well-designed but not working code. Even the roughest implementation is much better than what doesn't work or even isn't finished.
It is easier to make refactoring and structural improvements from the prototype / quick and dirty implementation, since there is a working link for testing.
As others have written, TDD is very useful because without proper tests it is very difficult to succeed with any refactoring project.
But finally, it is very important to separate the generalization in the problem area in which your program works, and the generalization in the entire domain of calculations.
Very often, projects end with the development of solutions for data structures, algorithms, network protocols, etc. instead of using existing implementations / libraries.
I have seen numerous examples where programmers implement their own hashmaps, http implementations, etc. instead of using existing ones. Sometimes, there might not be compatibility between the library and the application, but then the facade template could be used to encapsulate the use of an external library.
source share