liveBook · Manning

Encapsulation

Encapsulation is a software design principle that contains state and implementation details behind a controlled interface, limiting direct access from outside.

How 14 Manning books explain it

Simple Object-Oriented Design: Create clean, maintainable applications

Information hiding is the design technique of concealing likely-to-change implementation details behind a stable interface or abstraction.

How it is used
Protects object consistency and limits the impact of changing implementation details on clients.
How deep it goes
Develops refactorings for invariants, state checks, interfaces, and infrastructure boundaries, while deferring universal abstraction rules to context.
Examples
Uses training-offering enrollment and availability checks, update-email decisions, and a bot SDK adapter.
What you can do after
Apply it by moving rules and state checks behind intent-revealing operations and stable interfaces.

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

Unit Testing Principles, Practices, and Patterns

Encapsulation is the restriction of direct access to an object's internal state and the bundling of that state with controlled operations.

How it is used
Protects business invariants by making clients invoke complete operations through a controlled public API.
How deep it goes
Defines invariant protection, contrasts single- and multi-call APIs, and connects public behavior with hidden implementation details.
Examples
Uses customer purchases, inventory updates, single-line test actions, and domain boundaries in hexagonal architecture.
What you can do after
Evaluate APIs by checking whether one operation preserves complete outcomes and prevents clients from bypassing invariants.

Read how Unit Testing Principles, Practices, and Patterns explains encapsulation →

Practices of the Python Pro

Information hiding is the design practice of concealing implementation details that other code does not need to know.

How it is used
Uses encapsulation to separate complexity, control interfaces, and reduce dependencies in Python software design.
How deep it goes
Explains classes, modules, packages, privacy conventions, and refactoring, but stops short of enforced private access in Python.
Examples
Demonstrates shopping-cart boundaries, a Python Greeter refactoring, and a clean_query interface for search transformations.
What you can do after
Apply it via Python classes and modules, choosing narrow public interfaces and refactoring internal responsibilities as code evolves.

Read how Practices of the Python Pro explains encapsulation →

The Art of Code

Encapsulation is a design principle that restricts direct access to internal state and exposes controlled operations for maintaining object invariants.

How it is used
Separates stable report orchestration from interchangeable format-generation implementations.
How deep it goes
Examines consistency protection and boilerplate costs, then contrasts behavior encapsulation with concise data carriers.
Examples
Uses PDF, CSV, and Excel report generators plus Person constructors, a builder, and a boilerplate DTO.
What you can do after
Evaluate/understand when controlled operations protect meaningful rules and when simpler data modeling better preserves intent.

Read how The Art of Code explains encapsulation →

Web Components in Action

A software design technique that hides an object's internal state and implementation behind a simpler external interface.

How it is used
Uses encapsulation to make Web Components simple to consume while controlling access to their internal behavior and DOM.
How deep it goes
Explains interfaces, access protection, conventions, Shadow DOM boundaries, and accidental intrusions, while deferring broader implementation details.
Examples
Demonstrates custom elements, public add methods, external innerHTML changes, and accidental button selection across a component boundary.
What you can do after
Apply it via Web Components by designing a public API and protecting internal DOM with an open Shadow DOM boundary.

Read how Web Components in Action explains encapsulation →

100 C++ Mistakes and How to Avoid Them

Encapsulation is the software design principle of containing an entity's data and behavior within its representation and controlling access to that representation.

How it is used
Guides class design and legacy maintenance by protecting invariants while limiting client dependence on representation.
How deep it goes
Defines implementation hiding, explains invariant protection, and works through accessors and member-function choices without pursuing language internals.
Examples
Uses Circle accessors and Date formatting and output functions to contrast exposed representation with computed behavior and minimized dependencies.
What you can do after
Evaluate/understand whether class interfaces preserve invariants and permit representation changes without widespread client or method rewrites.

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

Object-Oriented Software Design in C++

Implementation hiding is the practice of concealing a class's internal data representation and function implementations behind an accessible interface.

How it is used
Uses class interfaces to isolate implementation changes and reduce dependencies among classes.
How deep it goes
Defines public, protected, and private access, then demonstrates change leaks through Date, sports, and subclass examples.
Examples
Uses private Date fields, duplicated sports algorithms, and Mammal subclasses with private state and behavior.
What you can do after
Evaluate/understand which members belong behind an interface and recognize duplication, coupling, and hardcoded behavior as leaks.

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

Software Design for Python Programmers

Implementation hiding is a software design technique that exposes only a class's necessary interface while concealing its internal representation and operations.

How it is used
Uses implementation hiding to reduce dependencies among classes and contain changes behind a stable public interface.
How deep it goes
Defines public, private, and protected members, then demonstrates change leakage through Date and sports design examples.
Examples
Uses private Date components and a sports hierarchy with duplicated venues and player-recruitment algorithms.
What you can do after
Apply it via private implementation members and a focused public interface that limits change propagation.

Read how Software Design for Python Programmers explains encapsulation →

Modern C, Third Edition

Encapsulation is the practice of containing implementation details and associated state within a program unit while exposing a callable interface.

How it is used
Uses function boundaries to isolate implementation details and per-call state while supporting recursive algorithms.
How deep it goes
Explains visibility, lifetime, fresh initialization, and cleanup of locals during nested and recursive calls.
Examples
Demonstrates independent call state through the recursive gcd2 implementation and its recursive call hierarchy.
What you can do after
Evaluate how function calls isolate identifiers and state across ordinary, nested, and recursive execution.

Read how Modern C, Third Edition explains encapsulation →

Python How-To

Encapsulation is the object-oriented design principle of restricting direct access to internal implementation details while exposing an appropriate interface.

How it is used
Applies access control to custom classes so users interact with a small, stable interface instead of internal helpers.
How deep it goes
Demonstrates public, protected, and private members plus read-only properties, but stops short of broader implementation internals.
Examples
Uses a Task class, a complete method, a format_note helper, and a read-only status property with AttributeError on assignment.
What you can do after
Apply it via Python classes, protected members, private methods, and properties that preserve controlled update paths.

Read how Python How-To explains encapsulation →

100 Go Mistakes and How to Avoid Them

Encapsulation is a software design technique that restricts direct access to state by placing it behind controlled operations or boundaries.

How it is used
Uses encapsulation to control package state, improve test isolation, and add behavior around struct-field access.
How deep it goes
Explains global-state consequences and getter/setter trade-offs with Go examples, stopping short of a general object-encapsulation framework.
Examples
Uses database initialization, static HTTP registration, time.Timer field access, and customer balance methods.
What you can do after
Diagnose when global state, init functions, direct fields, or accessors undermine testability, error handling, or useful behavior.

Read how 100 Go Mistakes and How to Avoid Them explains encapsulation →

Grokking Data Structures

Encapsulation is the bundling of data with the operations that manage it while restricting direct access to the data's internal representation.

How it is used
Uses classes to keep array state consistent and control operations that could otherwise corrupt internal data.
How deep it goes
Explains shared-state problems, class boundaries, composition, and invariant protection, but notes Python lacks true private class attributes.
Examples
Uses UnsortedArray and SortedArray constructors, size tracking, composition, and insert/delete operations as concrete examples.
What you can do after
Build it from scratch using Python classes that bundle state, delegate storage, and expose controlled operations.

Read how Grokking Data Structures explains encapsulation →

Functional Design and Architecture: Examples in Haskell

Encapsulation is a design and language mechanism that hides an entity’s internal representation while exposing a controlled interface.

How it is used
Protects object state and functional data representations from casual access, unstable dependencies, and localized mutation risks.
How deep it goes
Explains interface contracts, concurrency motivation, smart constructors, and module exports, while deferring detailed concurrency struggles.
Examples
Uses mutable concurrent variables, a Value algebraic data type, smart constructors, and a Haskell module export list.
What you can do after
Apply smart constructors and restricted module exports to keep clients independent of unstable internal representations.

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

Kotlin in Action, 2E

Information hiding is the design principle of concealing implementation details behind a restricted public interface.

How it is used
Protects class invariants by exposing only operations appropriate for external callers.
How deep it goes
Explains access boundaries through extension functions and private mutable versus public read-only flow types.
Examples
Uses String.lastChar and a RadioStation that privately emits shared-flow values for public subscribers.
What you can do after
Apply it via Kotlin visibility and flow types to prevent consumers from mutating internally controlled state.

Read how Kotlin in Action, 2E explains encapsulation →

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.