I've done some work for a personal project of mine, and now I understand why people tell us to plan out all our interfaces and design before coding. I've got some good classes and already have some working code, but all in all the the organization (architecture) is somewhat of a mess, and I'm already saying "If I did it again, I would do it like this...". The question is, should I sketch out a plan of how I want my code to look, and refactor the existing code to the new model, or if I should take what works great, and write all new code for the deficient parts (basically starting from scratch with a fair amount of copy and paste from this project).
I've got git history I'm not sure I want to lose, but the task of slowly rewriting everything seems daunting. So the question I'm asking is: when refactoring a young project, should one use evolution or revolution to get it right the second time?
Refactor the old code (evolution). Rewriting code always introduces problems that you didn't think of. I am sure there have been updates to the existing code, and a lot of those updates are bug fixes enhancements etc. You may not know why you made a change at the time, but you needed to, and rewriting the code could remove that needed change.
Taking small steps also helps you avoid the "Oh 'expletive'" scenario where you try and make some massive change and encounter a situation where it doesn't behave they way you expect it to. With evolution, you can back out a change and still have a working system since the architecture is somewhat finalized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With