# Defining Refactoring

{% hint style="warning" %}
If someone says their code was broken for a couple days while they were refactoring, you can be pretty sure they were not refactoring
{% endhint %}

* The term "refactoring" is often used very loosely by practitioners to mean any kind of code cleanup.&#x20;
* Refactoring is about applying small behavior-preserving steps and making a big change by stringing together a sequence of these behavior-preserving steps.
* During this process, code should NOT spend much time in a broken state.&#x20;

## **Refactoring (noun)**:&#x20;

a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing observable behavior.

## **Refactoring (verb)**:

to restructure software by applying a series of refactorings without changing its observable behavior.

## **Restructuring (verb)**:&#x20;

a general term to mean any kind of reorganizing or cleaning up of a code base that includes refactoring.

{% hint style="success" %}
Refactoring is always done to make the code easier to understand and cheaper to modify.
{% endhint %}


---

# 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://rob-richardson.gitbook.io/software-engineering/refactoring-improving-the-design-of-existing-code/chapter-2/defining-refactoring.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.
