# 任务10：打扫战场

在宣告最终胜利之前，我们再通盘审视一遍代码，看有什么需要清理的东西。

对了，别忘了最初接到镶金玫瑰的代码时，我们的目标是要支持“魔法召唤”（Conjured）物品。对现在的代码结构来讲，完成这个任务简直毫不费力，我就把它一起留给大家去完成了。

* 魔法召唤（Conjured）物品的贬值速度是普通物品的两倍。

## 你的任务

Java：

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

JavaScript：

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

1. 消除代码中残留的坏味道：重复代码、无用代码、代码命名等
2. 实现“魔法召唤”物品的业务逻辑
3. 要求小步前进，每一步修改之后马上运行所有测试，确保软件行为不变

## 反思

* 移除无用代码时，有没有把它当做跟其他手法一样的重构，认真遵循小步原则？

## 参考

* 《重构 2》6.1 提炼函数（Extract Function）
* 《重构 2》8.9 移除死代码（Remove Dead Code）


---

# 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/13-task-10.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.
