Member-only story

DDD — Entity and Value Types

Phillip Johnson
CodeX
Published in
4 min readFeb 27, 2022
Photo by Thomas Millot on Unsplash

What are Entity and Value Types in Domain Driven Design?

In Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans, Entity and Value Types are 2 of the fundamental building blocks that the concepts in the rest of the book are built on. Let’s take a look at what they are and why they matter.

Entities

In DDD, an Entity is something that has an identifier and an owner. It can be mutable, but has a thread of continuity throughout its lifetime. Let’s break that down using a car as an example:

  1. An Entity has an identifier: A good example of an Entity is a car, which is identified by its license plate.
  2. An Entity has an owner: If a car gets a parking ticket, or is involved in an accident, the authorities can find out who owns the car by looking at records that map a car to its owner. The owner can sell the car and transfer ownership to somebody else. The owner can also acquire a new car.
  3. An Entity can be mutable: An owner can change things on a car. They can change the wheels, the tires, the colour of the car, the engine and other parts. They can extend the car with body kits.
  4. An Entity has a thread of continuity: To return to the parking ticket example, if the car has changed…

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Phillip Johnson
Phillip Johnson

Written by Phillip Johnson

Over 20 years experience in software engineering, mostly in leadership positions. Passionate about software craftsmanship.

Responses (1)