Knowing when to hold 'em.

Member
Posts: 40
Joined: 2004.12
Post: #1
When those of you with more experience were starting out, how did you know when you should throw out your current project/code base for something that is better that would allow you to develop more effeciently, or to keep hacking out the program and have a ugly code base that works but may not be easy to correct or make adjustments to?

Jericho
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #2
Throw it out if you spend more time working around stupid hacks than you do creating new code (or stupid hacks Rasp )

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Member
Posts: 131
Joined: 2004.10
Post: #3
Joel on Software has some good articles applicable to any programming.
Things You Should Never Do, Part I
http://www.joelonsoftware.com/articles/f...00069.html

Note though, a lot of new programmers have to find things out before finding a right way to do it. Sure a lot of code may be tossed on the floor as being rubbish but there is probably quite a bit that is still salvagable. You've done a lot of work already, then try to reuse some of it, just refactor it into something more coherent.

Even skilled/pro programmers starting out in a domain they know nothing about will do things stupidly until they figure it out.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #4
I'd never throw out everything completely and rewrite from actual scratch. Sure, I'm rewriting my engine right now, but that is a structural rewrite, and a change of API:s. There is still so much stuff in there that is absolutely great, and I'm keeping the good parts. You should too. Smile
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #5
I wrote a 2D version of slicer in Java, then a proof of concept type thing with OpenGL. Then realised the majow flaws and did a rewrite to get what ive got now.
I have though extended and extended programs until they were terrible, it just depends on how you feel. I mean really it would be best to re-write any faulty code rather than provide ad-hoc fixes that arent as good solutions as you can think of, but it takes time some times that you might not have.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #6
Really, no code is wasted, even if you end up not using it. You learn (least I bloody hope so) from doing it. Rewriting something from scratch can be a very good thing. In your first design, you have likely made plenty mistakes simply because you had no idea what you had to do to reach your goal, or didn't even know what your goal was. If you try and fix things, you are likely to end up keeping fixing things forever.

By starting over, you have the chance to correct fundamental mistakes. And you can end up with a much leaner and meaner codebase to build upon. 2 years ago I rewrote a 15,000 line project of mine in a week, by starting from scratch, and ended up having the same functionality in only about 5,000 lines of code, and I could continue development at a much faster pace than with the previous spaghetti code.

I think if you discover fundamental mistakes in your approach, it's worthwile starting over. It doesn't mean you have to throw away everything, just start clean, and later merge the things that went right before into the new codebase.

However, if you haven't got a clue what's wrong, or what you could do better, starting over isn't likely to help.

And, before I forget: I usually throw something away when it's no longer fun to work on it. It's my hobby, and it better be bloody fun. Commercial projects are a different thing, but as long as you can, trust your instincts.

</end of rant>
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #7
Dog: on a much smaller scale Im on parallel to that, I thirded the size of the code and increased its efficiency fourfold and wrote it about five times the speed.. actually, Rasp
So I think people shouldnt be daunted when the idea of rewriting code comes up, if you can improve somthing, you really should..

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply