Java Reference
In-Depth Information
show duplicates simpler than sets the threshold size for a Java construct to be
considered during this analysis: 10 is the default and the minimum. (You don't
want every if statement to be reported as a duplicate of every other if statement
just because they share the same syntax. A construct needs to be a certain com-
plexity, a certain size, before the analysis process considers it.)
Anonymize uncommon subexpressions simpler than sets the threshold size
for considering subelements within Java constructs. For example, let's say you
have two large methods in your code that are identical except for a few lines. With
this setting at 0, the methods are considered sufficiently different and not dupli-
cates; with this setting at a higher value, the analysis may find the methods to be
duplicates, but with an uncommon subexpression .
If the Visible from outside of the scope only option is selected, the analysis
checks whether the discarded subelement is valid outside the current construct. If
the subelement is senseless, it can't be discarded and is considered nonduplicated.
9.4 I mproving code design through refactoring
Many professional developers are familiar with the concept of refactoring their
code. For the uninitiated, refactoring is the process of updating and improving the
internal design of software without changing its functionality. For example, you
may decide that a method inside an existing class should be pulled up into an
abstract class, allowing it to be reused across other classes. In this case, the new
code doesn't behave differently, but it now has a cleaner, more reusable structure.
IDEA can quickly and easily track down and correct the affected code references
automatically, even those within JSP code. Not only do IDEA 's automated features
ease the refactoring process, but they also encourage you to refactor more often—
leading to better software design.
9.4.1
Performing a refactoring
Performing a refactoring in IDEA is easy. Although each refactoring operation has
its own settings and options, the basic procedure is always the same.
How refactoring works
Although you can manually change the name of local variables easily enough, the
real benefits of a rename refactoring over manual manipulation are revealed
when you need to rename things on a larger scale, such as a class, package, or
widely used public method. In these circumstances, IDEA performs a number of
important tasks:
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search