-
Refactoring
refactoring
Refactoring
…is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
Its heart is a series of...
-
Extract Variable
Extract Variable
You have a complicated expression.
Put the result of the expression, or parts of the expression, in a temporary variable with a name that explains the purpose.
if ( (platform.toUpper...
-
Replace Iteration with Recursion
Replace Iteration with Recursion
Replace Iteration with Recursion
unsigned greatest_common_divisor (unsigned a, unsigned b)
{
while (a != b)
{
if (a > b)
{
a -= b;
}
else i...
-
Replace Recursion with Iteration
Replace Recursion with Iteration
Replace Recursion with Iteration.
image/svg+xml
Motivation
The old recruiting practice says, "Never hire a developer who computes the factorial using Recursion". Recur...
-
Replace Conditional with Polymorphism
Replace Conditional with Polymorphism
You have a conditional that chooses different behavior depending on the type of an object.
Move each leg of the conditional to an overriding method in a subclass....
-
Move Method
Move Method
A method is, or will be, using or used by more
features of another class than the class on which it
is defined.
Create a new method with a similar body in the class it uses most. Ei...