# 项目导学

## 项目介绍

镶金玫瑰是一道有趣的题目，而且它更加贴近于实战的项目代码：逻辑复杂，没有测试。一开始拿到题目时可能会望而生畏，但通过有条不紊的节奏、纪律严明的步骤手法，学员将能逐渐体会到重构的节奏感，对重构复杂的代码更有信心。

## 教学目标

1. 掌握重构的基本节奏
2. 养成重构前随时增补测试的习惯
3. 理解浮现式重构的工作方式
4. 掌握几项常见的重构手法：以多态取代条件表达式等
5. 通过刻意练习能在 30 分钟内完成题目的重构

## 项目学习时长

8 小时。

* 任务 1：1 h
* 任务 2：30 min
* 任务 3：30 min
* 任务 4：1 h
* 任务 5：1 h
* 任务 6：1 h
* 任务 7：30 min
* 任务 8：1 h
* 任务 9：1 h
* 任务 10：30 min

## 技能目标

1. 编写安全网测试；
2. 小步前进、随时回滚的安全重构；
3. 使用 IDE 的提示改善代码结构；
4. 消除魔法字符串；
5. 用工厂方法封装对象的创建过程；
6. 建立继承体系；
7. 用多态取代复杂的条件逻辑

## 参考资料

* 《重构 2》第 3 章：代码的坏味道


---

# 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/index.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.
