当您要向一个几乎没有 * 单元测试代码的大型(肮脏)代码库添加一些新功能时,您会怎么做? [英] What would you do when you are about to add some new features to a large (and dirty) codebase which has virtually *NO* unit-testing code?

查看:27
本文介绍了当您要向一个几乎没有 * 单元测试代码的大型(肮脏)代码库添加一些新功能时,您会怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Martin Fowler 说我们应该进行重构在添加新功能之前(因为原始程序结构不合理).

Martin Fowler says that we should do refactoring before adding new features (given that the original program is not well-structured).

所以我们都想重构这个代码库,这是肯定的.我们也知道,如果没有单元测试代码,很容易引入细微的错误.

So we all want to refactor this dirty codebase, that's for sure. We also know that without unit-testing code it's very easy to introduce subtle bugs.

但这是一个庞大的代码库.向其添加一整套测试似乎不切实际.

But it's a large codebase. Adding a complete suite of tests to it seems impracticable.

在这种情况下你会怎么做?

What would you do in this case?

推荐答案

我的建议是你尽可能少接触并添加你需要的东西.我发现最好别管闲事,尤其是在截止日期紧迫的情况下.

My suggestion would be that you touch as little as possible and add what you need. I have found that it is best to leave well enough alone, especially if you are on a tight deadline.

如果您进行过单元测试,那将是另一回事,但是当您更改代码时,就像触摸蜘蛛网一样.改变一件事会影响其他一切.

If you had had unit tests, that would be a different story, but when you change code it can be like touching a spider web. Changing one thing can affect everything else.

这篇关于当您要向一个几乎没有 * 单元测试代码的大型(肮脏)代码库添加一些新功能时,您会怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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