开发者

Cleaning Code: Fresh Start vs Hardcore Cleaning

so I got a budget to clean up code that I've inherited from another programmer. the code is in really bad shape, there's lots of files not being used, there's lots of functions not being used. It actually looks like linear programming instead of object oriented. My issue is whether or not I should

a) Clean the code, restructure it, and try to delete all unused resources b) start with a fresh framework (it's using codeigniter), and copy over the files that are needed to run

I like option b because it kind of reminds me of a new laptop from best buy. I can either spend the time removing all the bloatware or do a wipeout and create the system from scratch, which I always do. The only problem is that this time, there's a lot more involved then just creating a fresh system. Here are the pros and cons:

PROS

  • Clean system that is very easy to maintain
  • Don't need to go around searching for unused files
  • Easier to keep track of what I've done

CONS

  • Lots of things can break
  • Might miss required files
  • Might take longer

What do you think? Can you give me some of your pros and cons, and what you might do in a situation like this?

Update

A lot of people say that I am missing an important part, budget (time and money). We do have a decent budget, but my project manager is willing to go over if it ensures a more solid system with quicker turnaround time for new features. It's hard for me to quantify budget because you have not seen code, so giving hours won't hel开发者_运维问答p which is why I did not say anything about budget. I guess from your prospective, consider this a budget that can accommodate both solutions.


Often a hybrid approach works better. Keep the gold nuggets and toss the rest. Most likely there is some really effective code even in the worst project. Also, things that would be painful to rewrite and already work well, you might just clean those up a little.

It takes a little judgment to determine what to keep, but you can kind of have the best of both that way.


Cleaning someone else's code can be a nightmare. If you can actually choose and the stakeholders agree, I'd strongly recommend you to start over.

I had an experience like this last year and to this date, the software is still in pretty bad shape, it's almost impossible to track every mistake made by the programmers we inherited the code from and spend a LOT of time on support for hidden bugs and stuff.


I guess it somewhat depends on your time constraints and how intimately you'll need to know the project.

I just finished restructuring some code written by a math-majoring grad student. Bright guy, but he's not a programmer and the code was, as you said, very linear. Long story short, I rewrote about 90% of the code and took more time doing it than I would have liked. It would have been faster for me to start from scratch, using his code as a reference. Not only that, if I had planned on making as many changes as I had, I would have put more thought into the restructuring process. On the bright side, I now know all the code and concepts in this project very well.

On the other hand, if you don't plan on making many changes or having to maintain the code, maybe it's not worth the hassle. Get it to a usable state and tuck in back under the rug, so to speak.

My 2 cents...


This question reminds me of Joel's article I've read a while back.

The single worst strategic mistake that any software company can make: They decided to rewrite the code from scratch... It’s harder to read code than to write it.

http://www.joelonsoftware.com/articles/fog0000000069.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜