---
title: "Temporary Field"
type: "code-smell"
slug: "temporary-field"
url: "http://localhost:3000/en/smells/temporary-field.md"
category: "Object-Orientation Abusers"
description: "Temporary fields get their values (and thus are needed by objects) only under certain circumstances. Outside of these circumstances, they’re empty."
---
# Temporary Field

> Temporary fields get their values (and thus are needed by objects) only under certain circumstances. Outside of these circumstances, they’re empty.

## Signs and Symptoms

Temporary fields get their values (and thus are needed by objects) only under certain circumstances. Outside of these circumstances, they’re empty.

## Reasons for the Problem

Oftentimes, temporary fields are created for use in an algorithm that requires a large amount of inputs. So instead of creating a large number of parameters in the method, the programmer decides to create fields for this data in the class. These fields are used only in the algorithm and go unused the rest of the time.

This kind of code is tough to understand. You expect to see data in object fields but for some reason they’re almost always empty.

## Payoff

* Better code clarity and organization.
## Relations

**Treated by**

- [Extract Class](/en/extract-class.md)
- [Replace Method with Method Object](/en/replace-method-with-method-object.md)
- [Introduce Null Object](/en/introduce-null-object.md)

