liveBook · Manning

Code duplication

Also called duplicated code, duplicate code

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

How 6 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 →

High Performance Unity Game Development

The practice of implementing the same or similar code in multiple places instead of sharing one implementation.

How it is used
Separates implementations for different data sources to make source-specific bugs easier to locate.
How deep it goes
Explains risks of shared code and limits sharing to single-action transformations; it does not prescribe blanket deduplication.
Examples
Uses local and server save/load paths, including bugs caused by loading from an unexpected source.
What you can do after
Evaluate whether to duplicate source-specific behavior or share a single-action data transformation.

Read how High Performance Unity Game Development 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
Uses duplication as a maintainability concern when extending ACH storage and building reusable exception views.
How deep it goes
Shows duplicated-code examples and practical extraction into helper methods or a shared component.
Examples
Uses a duplicated database helper in ACH parsing and shared exception displays across pages.
What you can do after
Apply it by extracting repeated logic into helper methods or reusable components.

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

Also covered in

What to know first

Related concepts

Questions about code duplication

What is code duplication?

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

Which Manning books explain code duplication?

Software Design for Python Programmers, Object-Oriented Software Design in C++, 100 C++ Mistakes and How to Avoid Them, Test Driven: Practical TDD and Acceptance TDD for Java Developers, High Performance Unity Game Development and Build Financial Software with Generative AI (From Scratch).

What should I know before learning code duplication?

Manning books that teach code duplication usually introduce function, Map, software testing and abstract class first.

What is the difference between code duplication and reuse?

Code duplication is the presence of the same or substantially similar implementation logic in multiple locations within a software system. Reuse is the practice of applying existing software code, components, or behavior in additional contexts instead of reimplementing equivalent functionality.

What is code duplication a kind of?

Code duplication is a kind of code smell. A code smell is a recognizable characteristic of source code that suggests a potential design, implementation, or maintainability problem, without necessarily indicating a functional defect.

What is code duplication also called?

Code duplication is also called duplicated code or duplicate code.

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.