Advice from a long time ago that took me way longer than it should have to understand fully:
"Always throw the first one away."
I now consider the entire first prototype to be part of the "working out the design" process, and all the code written for that is considered disposable (quite often I write a prototype in a different language to the intended delivered product, partly to ensure I throw the first one away, but when I'm honest with myself - at least partly 'cause I enjoy rapid-prototyping in Perl.)