Split Temporary Variable

You have a temporary variable assigned to more than once, but is not a loop variable nor a collecting temporary variable.

Make a separate temporary variable for each assignment.


		double temp = 2 * (_height + _width);

		System.out.println (temp);

		temp = _height * _width;

		System.out.println (temp);




		final double perimeter = 2 * (_height + _width);

		System.out.println (perimeter);

		final double area = _height * _width;

		System.out.println (area);



For more information see page 128 of Refactoring

| Refactoring Home | | Alphabetical List |