|
|
|
A potential
solution to the long method problem is to identify parts of its code that can
stand on their own as methods. Replace
the original code with a call to the method.
This is rather difficult to automate, of course.
|
|
|
|
The second
example is pretty much common sense.
Despite this, there might be an example in our Sieve code. If the magic number appears several times,
it may be difficult to tell whether there is only one number or several.
|
|
|
|
Renaming some
variables, especially instance variables, may be quite complex. You don’t want the renamed variable to mask
variables in super classes or possibly get in the way of method variables. It may have to be changed in header files
and implementation files.
|
|
|
|
Explanatory
variables can often simplify long conditionals.
|
|
|