Code refactoring

refactoringrefactoredrefactorreengineeringre-engineeringfactoringre-factoredReengineering (software)software reengineeringbreaking large methods
Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.wikipedia
233 Related Articles

Technical debt

design debttoggle debtworkaround
Failure to perform refactoring can result in accumulating technical debt; on the other hand, refactoring is one of the primary means of repaying technical debt.

Code smell

code smellssmellssymptoms
Refactoring is usually motivated by noticing a code smell.
Often the deeper problem hinted at by a code smell can be uncovered when the code is subjected to a short feedback cycle, where it is refactored in small, controlled steps, and the resulting design is examined to see if there are any further code smells that in turn indicate the need for more refactoring.

Unit testing

unit testunit testsunit
Automatic unit tests should be set up before refactoring to ensure routines still behave as expected.
Unit testing allows the programmer to refactor code or upgrade system libraries at a later date, and make sure the module still works correctly (e.g., in regression testing).

Decomposition (computer science)

decompositionDecomposingfactoring
Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.

Type generalization

Generalize type
Type generalization is a technique commonly used in refactoring.

Cyclomatic complexity

Synchronization complexitycode complexitycomplex
Advantages include improved code readability and reduced complexity; these can improve source-code maintainability and create a more expressive internal architecture or object model to improve extensibility.
(Nowadays such a process would fall under the umbrella term of refactoring.) McCabe's reduction method was later called condensation in some textbooks, because it was seen as a generalization of the condensation to components used in graph theory.

Martin Fowler (software engineer)

Martin FowlerFowler, Martin
Martin Fowler's book Refactoring: Improving the Design of Existing Code is the canonical reference.
His 1999 book Refactoring popularised the practice of code refactoring.

Agile software development

Agileagile developmentAgile Manifesto
Proponents of extreme programming and other agile software development describe this activity as an integral part of the software development cycle.
Specific tools and techniques, such as continuous integration, automated unit testing, pair programming, test-driven development, design patterns, behavior-driven development, domain-driven design, code refactoring and other techniques are often used to improve quality and enhance product development agility.

Object-oriented programming

object-orientedobject orientedobject-oriented programming language
This facilitates code refactoring, for example allowing the author of the class to change how objects of that class represent their data internally without changing any external code (as long as "public" method calls work the same way).

Monorepo

LernaPantsPiper
A common strategy to allow safe and atomic refactors spanning multiple projects is to store all projects in a single repository, known as monorepo.

Extreme programming

XPcollective code ownershipcourage in programming
Proponents of extreme programming and other agile software development describe this activity as an integral part of the software development cycle.
Courage enables developers to feel comfortable with refactoring their code when necessary.

Rename method

rename a methodrenaming methods
Rename Method is a refactoring that changes a name of a method into a new one, that better reveals its purpose.

Duplicate code

code duplicationduplicated codeDuplication
For example, the method at hand may be very long, or it may be a near duplicate of another nearby method.
Refactoring duplicate code can improve many software metrics, such as lines of code, cyclomatic complexity, and coupling.

William Opdyke

Although refactoring code has been done informally for decades, William Griswold's 1991 Ph.D. dissertation is one of the first major academic works on refactoring functional and procedural programs, followed by William Opdyke's 1992 dissertation on the refactoring of object-oriented programs, although all the theory and machinery have long been available as program transformation systems.
William F. (Bill) Opdyke (born c. 1958) is an American computer scientist, and enterprise architect at JPMorgan Chase, known for his early work on code refactoring.

Extract class

In software engineering, the Extract Class refactoring is applied when a class becomes overweight with too many methods and its purpose becomes unclear.

IntelliJ IDEA

IntelliJIDEAJetBrains IntelliJ IDEA
The first version of IntelliJ IDEA was released in January 2001, and was one of the first available Java IDEs with advanced code navigation and code refactoring capabilities integrated.

Delphi (software)

DelphiBorland DelphiEmbarcadero Delphi
The code editor features Code Insight (code completion), Error Insight (real-time error-checking), and refactoring.

PyDev

PyDev plugin
It is an Integrated Development Environment (IDE) used for programming in Python supporting code refactoring, graphical debugging, code analysis among other features.

CodeRush

CodeRush Classic is a refactoring and productivity plugin by DevExpress that extends native functionality of Microsoft Visual Studio (Visual Studio .NET 2012, 2013, 2015, 2017 and 2019).

Microsoft Visual Studio

Visual StudioVisual Studio 2005Visual Studio 2008
Visual Studio includes a code editor supporting IntelliSense (the code completion component) as well as code refactoring.

Wing IDE

WingWing IDE ProfessionalWingIDE
Wing Pro provides local and remote debugging, editing (with multiple key bindings, auto-completion, and auto-editing), code intelligence, multi-selection, source browser and code navigation, code refactoring, unit testing, version control, Pylint integration, project management, search abilities, fine-grained customization, extension through Python scripting, and comprehensive documentation.

Subroutine

functionfunctionssubroutines
In extreme programming, the Extract Method refactoring technique has essentially the same meaning as factoring in Forth; to break down a "word" (or function) into smaller, more easily maintained functions.
If such coupling is not necessary, their advice is to refactor subroutines to accept passed parameters instead.

JetBrains

WebStormCLionRubyMine
The company's first product was IntelliJ Renamer, a tool for code refactoring in Java.

Eclipse (software)

EclipseEclipse IDEEclipse RCP
This allows for advanced refactoring techniques and code analysis.

Test-driven development

Test Driven Developmenttest-first developmentTDD
It is possible to write tests for low and easy maintenance, for example by the reuse of error strings, and this should be a goal during the code refactoring phase described above.