Split Temporary Variable

From CSSEMediaWiki
Revision as of 20:41, 6 August 2009 by Paul Williams (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is when you have create a temporary variable that you use all the way through a method. foo() int temp = 2 * (height + width); System.out.print(temp); temp = height * width; System.out.print(temp);

The variable has two different meanings at various stages of the method. Give each variable a descriptive name making it easier to understand the code.

foo() int perimeter = 2 * (height + width); System.out.print(perimeter ); area = height * width; System.out.print(area);

Personal tools