tags:

views:

155

answers:

5

Okay, I have been working lately on a script. I spend around 60 hours working on it. I finished with around 1k line of code. The script still missing few features, but in order to add those features, I need to alter some of the current functions in this script.

The result is that I have gone dark, it's even getting worse; new bugs and it seems like impossible to add the features and have a nice/good script that works as it should.

I don't want to re-code it from scratch, I didn't have a good plan and didn't structure the script, I thought it'll be a small one. It was my fault, but isn't there any solution???

+3  A: 

If you do not want to re-code it from scratch, then you will have to refactor it.

Figure out how to structure it, try to reuse code where possible, add documentation, ...

Peter Lang
+1  A: 

I'd be tempted to say scrapping it is the best option, but if you're absolutely against that, I'd start by refactoring it as much as you can, to improve the understandability of what is happening. The more readable the script is, the easier it is to fix its behavior (and find bugs). If possible, writing tests around new functionality would go a long way towards preventing this from happening in the future.

Matt Poush
A: 

If something gets too obfuscated/unreadable/unmaintainable for you, you have to rewrite it. The earlier you start, the better.

I'd start off with a new script and start merging features from the old script - test them, document them ... until you reach the old functionality.

Alexander Gessler
That would take horrible time, I have only 20 hours left before I need to deliver the product. I need also to write a documentation
Omar Abid
A: 

You suck it up as a lesson learned and you rewrite it.

Ideally, you can reuse some of the code, and make it a heavy refactoring job, but there will be a lot of redone work.

Milan Ramaiya
+2  A: 

Keep it lying around, but start anew.

When you need a chunk of code and you know it works for sure, drop it in.

Encapsulate those chunks of code: in a function, a class, whatever suits you.

Mark those blocks as possibly dirty in your comments.

Try to figure what a block a code is supposed to do and comment it.

If you have no idea what a block does, leave it there, rewrite it. Don't introduce it in your new program unless you recognize it and can write an explicative comment for it.

ZJR