当重写了一个code基 [英] When to rewrite a code base from scratch

查看:147
本文介绍了当重写了一个code基的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我回想起乔尔斯波斯基的文章关于从未从头开始重写code。综上所述他的观点:在code不生锈,虽然它可能不是经过多次维修版本看起来pretty,如果它的工作原理,它的工作原理。最终用户好好尝试一下保健pretty的code是如何。

I think back to Joel Spolsky's article about never rewriting code from scratch. To sum up his argument: The code doesn't get rusty, and while it may not look pretty after many maintenance releases, if it works, it works. The end user doens't care how pretty the code is.

您可以在这里阅读文章:事情你应该永远不会做

You can read the article here: Things You Should Never Do

我最近接手一个项目,并通过他们的code照看,这是pretty可怕。我立刻想到我以前已建成的原型,并明确表示,它不应该被用于任何生产环境。不过,当然,人们不听。

I've recently taken over a project and after looking through their code, it's pretty awful. I immediately thought of prototypes I had built before, and explicitly stated that it should not be used for any production environment. But of course, people don't listen.

在code是建立一个网站,有没有分离的顾虑,没有单元测试和code重复无处不在。无数据层,没有实际的业务逻辑,除非你算上APP_ code一堆类。

The code is built as a website, has no separation of concerns, no unit testing, and code duplication everywhere. No Data layer, no real business logic, unless you count a bunch of classes in App_Code.

我提出的建议向利益相关者,虽然我们应该保持现有的code,并做bug修复版本,以及一些小的功能版本,我们应该开始考虑测试驱动开发立即改写与关注明确分​​离。我考虑去的ASP.NET MVC的路线。

I've made the recommendation to the stake holders that, while we should keep the existing code, and do bug fix releases, and some minor feature releases, we should start rewriting it immediately with Test Driven Development in mind and with clear separation of concerns. I'm thinking of going the ASP.NET MVC route.

我唯一担心的是,当然,时间的长短可能需要从头开始重写。这是不完全复杂,其成员磨Web应用程序的pretty运行等。

My only concern is of course, the length of time it might take to rewrite from scratch. It's not entirely complicated, pretty run of the mill web application with membership, etc..

有任何你遇到过类似的问题?你采取任何特别措施?

Have any of you come across a similar problem? Any particular steps you took?

感谢一大堆!

更新:

所以..什么我最终决定做?我花了马特的做法,并决定重构许多领域。

So.. What did I end up deciding to do? I took Matt's approach and decided to refactor many areas.


  • 由于APP_ code是越来越而
    大,从而减慢了构建
    一次,我删除了许多类
    并转换它们放到一个类
    库。

  • 我创建了一个非常简单的数据访问
    层,包含了所有的ADO的
    调用,并创建了一个提供SQLHelper对象
    执行这些调用。

  • Since App_Code was getting rather large and thus slowing down the build time, I removed many of the classes and converted them into a Class Library.
  • I created a very simple Data Access Layer, which contained all of the ADO calls, and created a SqlHelper object to execute these calls.

我实现了一个更清洁的记录结果
解决方案,这是更为简洁。

I implemented a cleaner logging
solution, which is much more concise.

虽然我在这个项目上不再工作[资金,政治,等等等等]我觉得它给了我一些巨大的洞察到一些项目怎么不好可以写,步骤一个开发人员可以采取使事情变得更清洁,可读只是平了小的,渐进的步骤随着时间的推移更好。

While I no longer work on this project [funding, politics, blah blah], I think it gave me some enormous insight into how bad some projects can be written, and steps one developer can take to make things a lot cleaner, readable and just flat out better with small, incremental steps over time.

再次感谢大家谁评论说。

Thanks again to everyone who commented.

推荐答案

只是因为它拥有所有这些问题,现在并不意味着它有继续拥有他们。如果你发现自己的,可以从,比如说,一个新的数据层中获益系统做出具体bug修复,然后创建一个新的数据层。只是因为整个网站没有使用,这并不意味着你不能开始使用的。重构,你在你的错误修复需要。并确保你明白到底是什么code是在帮你改变它。

Just because it has all those problems now doesn't mean it has to continue to have them. If you find yourself making a specific bug fix in the system that could benefit from, say, a new data layer, then create a new data layer. Just because the whole site doesn't use it doesn't mean you can't start using one. Refactor as you need to during your bug fixes. And make sure you understand exactly what the code is doing before you change it.

问题与code重复?拉出来成一个类或实用工具库,在一个中心位置下一次你要修复一个bug在重复code。

Problem with code duplication? Pull it out into a class or utility library, in a central location next time you have to fix a bug in the duplicated code.

和,因为已经被其他反应提到 - 现在就开始写测试。这可能是很难如果code是加上因为它的声音,但你可能开始的地方。

And, as already mentioned by other responders - start writing tests now. It may be hard if the code is a coupled as it sounds, but you can probably start somewhere.

有没有好的理由来重写工作code。但是,如果你已经修复bug,没有理由不能返工code有更好的设计特定部分。

There is no good reason to rewrite working code. However, if you are already fixing a bug, there is no reason you can't rework that specific part of the code with a "better" design.

这篇关于当重写了一个code基的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆