liveBook · Manning

Refactoring

Refactoring is the restructuring of existing software or code to change its internal organization and improve its design, typically while preserving externally observable behavior.

How 22 Manning books explain it

Practices of the Python Pro

Refactoring is the process of changing a software system's internal design without changing its externally observable behavior.

How it is used
Uses incremental design improvement to keep evolving Python systems readable, maintainable, performant, and easier to change.
How deep it goes
Explains motivations, timing, decomposition, abstraction, and short Python transformations, but stops short of a comprehensive refactoring catalog.
Examples
Demonstrates state-capital extraction, Greeter restructuring, frequency counting, checkout decomposition, conditional mapping, and decoupled command messaging.
What you can do after
Apply it via Python by extracting responsibilities, replacing rigid conditionals, choosing clearer built-ins, and preserving existing behavior during change.

Read how Practices of the Python Pro explains refactoring →

Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

Refactoring is the disciplined restructuring of an implementation without changing its externally observable behavior.

How it is used
Restructures IaC monoliths to isolate conflicts, reduce deployment time, limit blast radius, and meet security standards.
How deep it goes
Explains definitions, technical debt, dependency ordering, state imports, verification, cleanup, and failure containment without detailing every provider operation.
Examples
Uses GCP IAM extraction, separate directories and state, Terraform plans, and dependency-ordered project, network, database, server, load balancer, and DNS configurations.
What you can do after
Apply refactoring via Terraform by copying configurations, importing resources, validating plans, removing old state, and repeating by dependency order.

Read how Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform explains refactoring →

"Looks Good to Me"

AI-assisted restructuring of code directly within a code-review workflow while proposing an immediately integrable change.

How it is used
Deploys AI-assisted refactoring inside pull-request review to address feedback and improve proposed changes.
How deep it goes
Explains targeted and extended suggestions, but defers final decisions and contextual judgment to humans.
Examples
Uses What The Diff’s singleton suggestion and Qodo’s /improve and --extended commands as concrete workflows.
What you can do after
Apply it via What The Diff or Qodo to propose review changes, then validate and integrate suitable patches.

Read how "Looks Good to Me" explains refactoring →

Refactoring to Rust

A software-engineering process of restructuring existing code to improve qualities such as performance or maintainability without replacing the whole system.

How it is used
Improves selected parts of a running application while preserving service and avoiding a wholesale rewrite.
How deep it goes
Defines the scope of a refactor and gives deployment and testing rationale, then illustrates language integration through a concrete replacement.
Examples
Uses a Python Mandelbrot function moved into a PyO3 Rust module, with a later change that releases the global interpreter lock.
What you can do after
Practice/perform a small replacement, verify its existing contract, and deploy it in changes whose failures can be traced.

Read how Refactoring to Rust explains refactoring →

Shipping Go: Develop, deliver, discuss, design, and go again

Refactoring is the restructuring of existing source code to improve its internal design without changing its externally observable behavior.

How it is used
Simplifies code or tests after a passing test so the next small change is easier to make.
How deep it goes
Works through a test-structure change and its verification, rather than a broad catalog of refactoring techniques.
Examples
Uses Go translation tests that replace repeated assertions with cases for English, German, Finnish, and Dutch.
What you can do after
Practice/perform it by simplifying a passing test or implementation and rerunning tests before adding another behavior case.

Read how Shipping Go: Develop, deliver, discuss, design, and go again explains refactoring →

The Art of Code

Refactoring is the restructuring of existing code to improve its design or clarity without changing its externally observable behavior.

How it is used
Improves clarity and maintainability in complex business logic and legacy code by revealing structure and intent.
How deep it goes
Demonstrates repeated structural simplification with extraction, nesting reduction, streams, metrics, and risk assessment rather than treating refactoring as one pass.
Examples
Uses a long-method rewrite exercise and email-reminder delivery refactored through extracted methods and streams.
What you can do after
Practice/perform it by decomposing long methods, lowering unnecessary nesting, and judging regression risk before simplifying existing code.

Read how The Art of Code explains refactoring →

Coding with AI

Code refactoring is the restructuring of existing source code to improve its internal organization without changing its externally observable behavior.

How it is used
Uses AI to inspect existing code, propose maintainability improvements, generate tests, and compare implementation trade-offs.
How deep it goes
Descends from a brief definition to worked Python changes and verification, while stopping short of guaranteeing generated code correctness.
Examples
Demonstrates session-aware question retrieval, shared database cursors, import correction, browser refresh behavior, console output, and generated tests.
What you can do after
Diagnose/debug with it by reviewing AI suggestions, preserving behavior, testing edge cases, and validating application and database state.

Read how Coding with AI explains refactoring →

Grokking Simplicity

The systematic restructuring of existing code without changing its externally observable behavior.

How it is used
Uses behavior-preserving restructuring to separate calculations from actions and improve reuse, testing, and maintenance.
How deep it goes
Works through extraction, explicit inputs and outputs, code smells, callbacks, loop rewrites, and small-step decomposition.
Examples
Demonstrates shopping-cart totals, duplicated field setters, nested loops, array windows, callbacks, and functional map and reduce chains.
What you can do after
Apply it via incremental transformations that expose data flow, remove duplication, replace loops, and reduce bug-prone mutable state.

Read how Grokking Simplicity explains refactoring →

The Quick Python Book, Fourth Edition

Refactoring is the systematic restructuring of existing source code to improve its internal qualities without changing its externally observable behavior.

How it is used
Uses refactoring to improve working Python programs as new ways to organize and express their logic become available.
How deep it goes
Works through shorter expressions and function extraction, including memory and naming pitfalls, rather than prescribing a universal refactoring procedure.
Examples
Reworks a word counter, extracts text-processing functions, and reorganizes a word-frequency program into a package.
What you can do after
Practice/perform focused Python rewrites and check generated code for resource trade-offs, missing imports, and name collisions.

Read how The Quick Python Book, Fourth Edition explains refactoring →

Software Testing with Generative AI

Refactoring is the restructuring of existing source code to improve its internal design without changing its externally observable behavior.

How it is used
Uses refactoring within TDD to improve production code while preserving passing checks.
How deep it goes
Explains the red/green/refactor sequence and risk-led review, but does not detail named refactoring transformations.
Examples
Uses a Java Timesheet implementation, AI-generated accuracy and consistency risks, and the red/green/refactor cycle.
What you can do after
Apply it via TDD and unit-checking tools while using human judgment to verify AI-identified risks.

Read how Software Testing with Generative AI explains refactoring →

The Art of Unit Testing 3e

Refactoring is changing the internal structure of code without changing its externally observable functionality.

How it is used
Supports test-driven development and legacy-code change by improving structure while preserving already tested behavior.
How deep it goes
Defines refactoring and gives incremental, test-backed procedures, while deferring detailed techniques and gotchas to another reference.
Examples
Uses method renaming, method splitting, and an XML configuration manager protected by real-system integration tests.
What you can do after
Apply it via incremental code changes and repeated tests, including integration-test baselines when legacy code lacks unit tests.

Read how The Art of Unit Testing 3e explains refactoring →

Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

Internal refactoring is structural change confined within a program or module that preserves its external behavior and interfaces.

How it is used
Makes Terraform modules easier to maintain and extend while keeping internal changes mostly invisible to users.
How deep it goes
Defines the interface boundary and gives file-reorganization guidance, plan expectations, and test checks; it does not provide a full refactoring procedure.
Examples
Uses grouped networking, load-balancing, and logging variables, plus splitting an oversized main.tf by function.
What you can do after
Practice/perform internal module reorganization and check for unintended changes with tests and a Terraform plan.

Read how Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu explains refactoring →

Python How-To

Refactoring is the restructuring of existing code to improve its design or maintainability without changing its externally observable behavior.

How it is used
Guides maintainability work by removing duplication, clarifying class responsibilities, and consolidating repeated test setup.
How deep it goes
Explains the behavior-preserving goal and demonstrates extraction in formatting, testing, and class design without discussing implementation internals.
Examples
Demonstrates repeated f-string formatting, a parameterized formatting function, a split class design, and unittest setUp.
What you can do after
Apply it by extracting repeated formatting or test setup and separating classes whose responsibilities have become mixed.

Read how Python How-To explains refactoring →

Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

Continuous refactoring is the repeated restructuring of software during development without changing its externally observable behavior.

How it is used
Uses continuous restructuring to keep software simple during development and to convert monoliths into microservices incrementally.
How deep it goes
Explains iterative steps, testing, natural seams, and delivery constraints, but defers detailed conversion tactics to individual monoliths.
Examples
Shows simple architectural design, incremental monolith extraction, natural seams, and Terraform code refactoring.
What you can do after
Apply refactoring through small tested changes while preserving a working product and preparing components for extraction.

Read how Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform explains refactoring →

Build Financial Software with Generative AI (From Scratch)

Refactoring is the restructuring of existing code to improve its organization or maintainability without changing its externally observable behavior.

How it is used
Uses restructuring to clarify application components, simplify internal syntax, and reduce repeated test code during incremental development.
How deep it goes
Walks through extraction, simplification, and test generalization, but stops short of prescribing a comprehensive refactoring catalog.
Examples
Demonstrates navigation extraction, BDD-style syntax cleanup, regular-expression replacement, and generalized ACH exception tests.
What you can do after
Apply it via Next.js, Material UI, Python test code, or database-processing code to make existing implementations clearer and easier to test.

Read how Build Financial Software with Generative AI (From Scratch) explains refactoring →

Simple Object-Oriented Design: Create clean, maintainable applications

Refactoring is the disciplined transformation of existing software structure without changing its externally observable behavior.

How it is used
Controls growing software complexity by continually improving object-oriented design as needs and understanding change.
How deep it goes
Explains planning, small-step practice, renaming, extraction, encapsulation, and redesign timing through a worked conditional example.
Examples
Uses a billing-system redesign and an employee update-email conditional rewritten into named decision methods.
What you can do after
Practice/perform incremental structural improvements that clarify code, localize rules, and address complexity before it becomes entrenched.

Read how Simple Object-Oriented Design: Create clean, maintainable applications explains refactoring →

Learn AI-Assisted Python Programming, Second Edition

Code refactoring is the restructuring of existing code to improve its readability or maintainability without changing its intended behavior.

How it is used
Organizes growing programs into clearer, more maintainable functions while preserving behavior.
How deep it goes
Explains decomposition and reorganization through examples, but stops short of detailed implementation internals.
Examples
Uses order processing, word extraction, signature calculation, and configurable feature weights.
What you can do after
Apply it by splitting functions, extracting repeated tasks, relocating decisions, and checking that behavior remains unchanged.

Read how Learn AI-Assisted Python Programming, Second Edition explains refactoring →

Rust Servers, Services, and Apps

Code refactoring is the restructuring of existing source code without changing its externally observable behavior.

How it is used
Applies structural changes to a Rust web project while preserving its externally observable behavior.
How deep it goes
Walks through file moves, module declarations, import updates, compilation, and tests, but does not detail behavioral refactoring.
Examples
Uses handler relocation, folder-based module grouping, updated imports, cargo check, and cargo test.
What you can do after
Apply it to reorganize a Rust project and verify the result through compilation and tests.

Read how Rust Servers, Services, and Apps explains refactoring →

The Well-Grounded Python Developer: How the pros use Python and Flask

Refactoring is restructuring existing code to improve its design or maintainability while preserving its intended behavior.

How it is used
Improves maintainability by separating responsibilities and preserving flexibility for later reuse.
How deep it goes
Explains separation and function extraction through practical examples, without detailing a broader refactoring catalog.
Examples
Uses a calculation-formatting-output split and the extraction of long functions into focused functions or class methods.
What you can do after
Apply refactoring by splitting mixed responsibilities, extracting focused functions, and grouping related operations into classes when appropriate.

Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains refactoring →

Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

The systematic restructuring of existing software code without changing its externally observable behavior.

How it is used
Simplifies a robot motor library while preserving its public movement functions and arguments.
How deep it goes
Explains shared-logic extraction, parameter passing, wrappers, and library reuse, but does not develop broader refactoring techniques.
Examples
Uses repeated DC-motor movement code, a centralized movement function, directional wrappers, and commonmotor.py.
What you can do after
Apply it via Python functions to simplify motor-control code without altering callers or robot movement behavior.

Read how Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi explains refactoring →

Functional Design and Architecture: Examples in Haskell

Refactoring is the disciplined restructuring of existing code without intentionally changing its externally observable behavior.

How it is used
Uses restructuring to recover maintainability when code has accumulated incorrect dependencies, inappropriate responsibilities, or inconsistent domain representations.
How deep it goes
Descends from recognizing design decay to changing data types, declarations, names, and module boundaries, without detailing testing or behavioral verification.
Examples
Uses hardware descriptions, component passports, vendor declarations, magic constants, naming inconsistencies, and invalid component combinations.
What you can do after
Apply it via Haskell or Scala type systems and functional approaches to make substantial model and naming changes safer.

Read how Functional Design and Architecture: Examples in Haskell explains refactoring →

Think Like a Software Engineering Manager

Refactoring is the restructuring of software code to improve its internal quality without changing its externally intended behavior.

How it is used
Uses refactoring to reduce technical debt while balancing product-feature delivery.
How deep it goes
Defines refactoring through technical-debt management and supplies review questions, but stops short of implementation techniques.
Examples
Uses deadline-driven shortcuts, duplicate code, incomplete features, design reviews, and future architectural revision as examples.
What you can do after
Evaluate technical debt by questioning duplication, modularity, review quality, testing, documentation, and system-wide effects.

Read how Think Like a Software Engineering Manager explains refactoring →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.