# 任务3：简单清扫

测试的安全网搭建好，我们即将迈出重构征程的第一步。第一步怎么迈，有讲究。请同学们花 3 分钟，瞅一下代码，看看你最想开始重构的代码是哪一坨？

![](/files/-LrtW0qpl9efFLdCkSLo)

相信不少同学已经看到了中间那坨深深嵌套的代码，扬言要“擒贼先擒王”，大有战略上无限藐视敌人的气势。这种信心很有必要，但是且慢！你可能又犯了低估祖传代码的毛病。

祖传代码变成今天这个难以维护的样子，不是某一天、某一次修改造成的，而是无数次不审慎、不讲究的修改日积月累而来的。祖传代码的问题也不可能靠一次修改就马上解决。面对一大块祖传代码，最合适的入手点不是上来就挑战其中最困难的部分，而是先做一些最基本、最简单的整理，让代码变得稍稍整洁一点。这些整理工作也许看起来简单到有点弱智的程度，但它会给你信心，让你敢于开始一点点修改祖传代码，并且逐渐找到小步修改、频繁运行测试的节奏。

## 你的任务

Java：

```
git checkout task-3-cleanup
./gradlew clean build
```

JavaScript：

```
git checkout task-3-cleanup
npm test
```

1. 对代码的各处小问题做简单的整理
2. 要求小步前进，每一步修改之后马上运行所有测试，确保软件行为不变

## 反思

* 你发现从哪些地方开始最简单？
* 你如何寻找这些可以简单修改的地方？
* 有没有频繁运行测试？


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ethan-lin.gitbook.io/refactoring/xiang-jin-mei-gui/5-task-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
