Glossary · Automation software engineering and architecture
Refactoring
Also known as: Code refactoring
German: Refactoring
In software engineering, refactoring is restructuring existing code to improve its internal quality, such as readability, structure or testability, without changing its externally observable behavior.
- Software engineering
In one sentence
Refactoring restructures existing code to improve its internal quality without changing its externally observable behavior.
Example
The team splits a 3,000-line PLC program into function blocks per station and runs the full regression test suite to confirm that the machine behaves exactly as before.
How it applies
- Engineering: Refactoring is done in small steps, each verified by tests. Without an automated Regression test suite, refactoring becomes risky rewriting.
- Change control: Even without intended behavior change, refactoring changes code. For safety-related or validated software it goes through Change control and Impact analysis like any modification.
- Documentation: User documentation should not change after pure refactoring; if it must, the behavior changed. Internal design documentation, however, needs updating to reflect the new structure.
Refactoring vs. rewrite
Refactoring preserves behavior and proceeds incrementally. A rewrite replaces code wholesale and typically changes behavior, with higher risk. Refactoring is the usual way to repay Technical debt.