liveBook · Manning

Code duplication

Code duplication is the presence of the same or substantially similar implementation logic in multiple locations within a software system.

How 5 Manning books explain it

Software Design for Python Programmers

Duplicate code is the presence of multiple substantially similar copies of an implementation in a program.

How it is used
Diagnoses repeated implementations as a design smell during incremental object-oriented refactoring.
How deep it goes
Defines duplication, traces maintenance consequences across examples, and demonstrates shared implementations without fully specifying every refactoring.
Examples
Uses book catalogues, toy behaviors, sports reports, fundraising workflows, sports algorithms, and collection-specific player iteration.
What you can do after
Apply it via shared functions, cohesive classes, or design patterns that centralize common behavior and isolate variants.

Read how Software Design for Python Programmers explains code duplication →

Object-Oriented Software Design in C++

Code duplication is the presence of multiple copies of substantially similar implementation logic in a program.

How it is used
Uses duplication as a practical signal for finding poor design, maintenance hazards, and change leaks.
How deep it goes
Explains causes and consequences through several C++ examples, then points to shared functions, cohesive classes, and design patterns.
Examples
Illustrates duplication with book catalogues, sports reports, fundraising clients, and team reports over arrays, vectors, and maps.
What you can do after
Evaluate/understand repeated logic and consolidate it into shared functions, cohesive classes, or appropriate design-pattern structures.

Read how Object-Oriented Software Design in C++ explains code duplication →

100 C++ Mistakes and How to Avoid Them

Code duplication is the presence of repeated or substantially similar source-code logic in multiple locations.

How it is used
Frames duplication as a maintenance concern while distinguishing shared knowledge from control flow that merely looks similar.
How deep it goes
Works through refactoring examples and recommendations, but does not develop a general method for detecting duplication.
Examples
Contrasts repeated Cylinder calculations with helper-based refactoring and compares combined versus separate positive-and-negative filters.
What you can do after
Evaluate repeated logic and refactor shared knowledge without forcing distinct behaviors into a flag-driven function.

Read how 100 C++ Mistakes and How to Avoid Them explains code duplication →

Test Driven: Practical TDD and Acceptance TDD for Java Developers

Code duplication is the repetition of the same or similar code in multiple places in a software system.

How it is used
Guides refactoring by identifying repeated code or responsibilities that make changes harder.
How deep it goes
Explains maintenance risks and demonstrates removing duplication from tests with shared setup and a helper method.
Examples
Uses repeated template-engine tests, shared fixtures, and a parser helper to illustrate removing redundancy.
What you can do after
Apply it by extracting common test setup while preserving test intent and behavior.

Read how Test Driven: Practical TDD and Acceptance TDD for Java Developers explains code duplication →

Build Financial Software with Generative AI (From Scratch)

Code duplication is the repetition of substantially similar implementation logic in multiple places within a software system.

How it is used
Guides maintainability work while expanding ACH processing and exception views.
How deep it goes
Demonstrates duplicated methods and page logic, then applies extraction and component reuse without formal measurement or taxonomy.
Examples
Uses duplicated get_db code, ACH parsing, and a shared exceptions DataGrid component.
What you can do after
Apply it by extracting duplicated methods into helpers or reusable components and evaluating component data flow.

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

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.