为了重构庞大的代码库,我应该记住什么? [英] What should I keep in mind in order to refactor huge code base?

查看:16
本文介绍了为了重构庞大的代码库,我应该记住什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在庞大的代码库(18000 多个 Java 类)中重构某些部分.目标是能够提取较低层作为独立库,以便在当前使用此代码库副本的其他项目中重用.尤其有兴趣的部分被重构为独立于业务逻辑的框架.最终,我希望代码具有清晰的架构分层.

I'm going to refactor certain parts in a huge code base (18000+ Java classes). Goal is to be able to extract lower layers as independent libraries to be reused in other projects that currently use duplicate of this code base. Especially one part is of interest to be refactored into a framework independent of business logic. Ultimately I would like the code to have a clean architectural layering.

我使用名为 Structure 101 for java 的工具查看了代码,发现了许多 (!) 架构分层问题,其中低层引用了上层.

I've looked at the code with a tool called Structure 101 for java and found lots (!) of architectural layering issues where lower layers are referencing upper layers.

我不想简单地开始弄乱代码,而是尝试想出一个合理的策略来解决这个问题.我应该注意哪些事项?

I don't want to simply start messing with the code but try to come up with a reasonable strategy to go about this problem. What things should I keep in mind?

我正在考虑至少采取一些小步骤.我也在考虑进行单元测试,但这需要创建它们,因为没有.

I'm thinking about at least taking small steps. I'm also thinking about have unit tests in place, but that requires creating them, since there are none.

对此有什么想法吗?

推荐答案

您还应该查看 Michael Feathers 的使用遗留代码"一文:

You should also take a look at Working with legacy code by Michael Feathers:

http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/ref=sr_1_1?ie=UTF8&s=books&qid=1242430219&sr=8-1

我认为您可以进行的最重要的事情之一是测试以确保在重构​​/拉出到单独的模块后一切仍然有效.添加一个持续集成系统,在您签入时运行您的测试.

I think one of the most important things you can put in place to facilitate this are tests to ensure that everything still works post refactoring/pulling out into separate modules. Add to this by introducing a continuous integration system that runs your tests when you check something in.

这篇关于为了重构庞大的代码库,我应该记住什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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