liveBook · Manning

Incremental refactoring

As explained in Refactoring to Rust

Incremental refactoring is a technique for restructuring software through a sequence of small, controlled changes rather than a single comprehensive rewrite.

Incremental refactoring restructures a mature production system through small, controlled changes instead of a big-bang rewrite. It balances performance improvements and technical-debt reduction with ongoing feature delivery, user requests, and service reliability. section 1.0

A practical incremental refactoring process uses four stages:

  • Plan the improvement target, the code to change, and the interface between existing and new code. section 1.6
  • Mirror existing functionality in Rust, then integrate the new implementation into the existing codebase. section 1.6
  • Verify new functionality with Rust testing facilities and compare results from existing and new code paths. section 1.6
  • Choose a deployment approach that rolls out the refactored code without affecting end users. section 1.6

Rust supports this approach with strong typing, ownership and lifetime guarantees, direct memory sharing across FFI boundaries, and thread-safety guarantees. These features can target memory safety in C or C++ systems and performance in interpreted, garbage-collected systems such as Python. section 1.3 section 1.6

Figure 1.2 Overview of the refactoring process that we discuss in this book
figure

Use the process overview to trace planning, implementation, verification, and deployment as connected stages. section 1.6

How Refactoring to Rust covers it

How deep it goes
Breaks the practice into planning, implementation, verification, and deployment, but leaves integration variations and detailed rollout choices open.
Examples
Uses C, C++, or Python systems, mirrored Rust implementations, cross-path tests, FFI boundaries, and staged production rollouts.
What it assumes
Assumes an existing production codebase, existing functionality to mirror, and tests that can compare old and new behavior.
What you can do after
Apply it to plan, implement, verify, and deploy Rust replacements inside an existing application.
How it connects
Connects memory safety, performance, technical debt, FFI, ownership, lifetimes, type systems, thread safety, testing, and deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.