liveBook · Manning

Value object

Also called value types

A value object is an object whose meaning and equality are determined by its attribute values rather than by an independent identity.

How 5 Manning books explain it

Unit Testing Principles, Practices, and Patterns

A value object is an immutable object identified solely by its content rather than by an individual identity.

How it is used
Guides dependency substitution and output-based testing by separating immutable values from mutable state.
How deep it goes
Defines identity and immutability, then shows .NET equality implementation; it stops short of broader construction guidance.
Examples
Uses the integer 5, Product.Shampoo, FileUpdate, and audit-file instructions as concrete value examples.
What you can do after
Apply value equality to simplify output assertions and avoid substituting immutable dependencies with test doubles.

Read how Unit Testing Principles, Practices, and Patterns explains value object →

Clean Applications with Hexagonal Architecture

A value object is an immutable domain object defined by its attributes rather than identity and responsible for enforcing the constraints of the concept it represents.

How it is used
Replaces scattered primitive validation with explicit, self-validating concepts in a framework-free domain core.
How deep it goes
Works through constructor validation, value equality, multi-attribute behavior, and factories that accumulate errors.
Examples
Uses Title, ArticleId, Content, and PublicationPeriod to demonstrate constraints, typed parameters, and date-based behavior.
What you can do after
Build value objects from scratch with construction-time validation and explicit error handling.

Read how Clean Applications with Hexagonal Architecture explains value object →

Java Persistence with Spring Data and Hibernate epub

A developer-defined value type is an application-defined class whose instances are identified by their values rather than independent persistent identity.

How it is used
Uses value types to model domain objects owned by entities without independent persistent identity.
How deep it goes
Explains ownership, shared references, embedded table layout, and dependent collections, while separating transactional file deletion from database lifecycle.
Examples
Compares separate and shared addresses for two users, embeds home and billing addresses in USERS, and describes an Item’s Image collection.
What you can do after
Evaluate whether a domain class needs entity identity or can be owned and persisted as a value type.

Read how Java Persistence with Spring Data and Hibernate epub explains value object →

Data-Oriented Programming in Java

A value object is an object that represents an immutable value and is distinguished by equality of its properties rather than by object identity.

How it is used
Models domain data as immutable state whose meaning does not depend on object identity.
How deep it goes
Defines value semantics, demonstrates equality and mutation hazards, and develops immutable updates and record-based implementations.
Examples
Uses Vector equality, composite Ball and InvoiceDetails models, mutable Date failures, and successive Ball simulation frames.
What you can do after
Build it from scratch with immutable state, state-based equality, and hashing, or express it tersely with Java records.

Read how Data-Oriented Programming in Java explains value object →

The Joy of JavaScript

An immutable object whose equality and identity are determined by its attribute values rather than by a stable external identifier.

How it is used
Represents domain values such as money, dates, points, lines, and decimals within composable application code.
How deep it goes
Defines design rules and demonstrates JavaScript freezing, sealing, equality, arithmetic, and primitive conversion.
Examples
Uses Money, DateTime, Point, Line, Decimal, coordinate mutation, and currency-specific arithmetic examples.
What you can do after
Build it from scratch as a sealed, frozen JavaScript object with value-based equality and composable operations.

Read how The Joy of JavaScript explains value object →

Also covered in

What to know first

Related concepts

Questions about value object

What is value object?

A value object is an object whose meaning and equality are determined by its attribute values rather than by an independent identity.

Which Manning books explain value object?

Unit Testing Principles, Practices, and Patterns, Clean Applications with Hexagonal Architecture, Java Persistence with Spring Data and Hibernate epub, Data-Oriented Programming in Java and The Joy of JavaScript.

What should I know before learning value object?

Manning books that teach value object usually introduce encapsulation, entity, enum and hexagonal architecture first.

What is the difference between value object and @Entity?

A value object is an object whose meaning and equality are determined by its attribute values rather than by an independent identity. @Entity is a Jakarta Persistence annotation that marks a Java class as a persistent entity managed by a persistence provider.

What is value object a kind of?

Value object is a kind of immutable collection. An immutable collection is a collection whose contents cannot be changed after it is created.

What is value object also called?

Value object is also called value types.

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.