Objects defined as entities

As we have seen, having objects primarily defined by their properties can be really useful and helps us deal with a lot of scenarios when designing a system. So, we often see that certain objects have a different lifecycle attached to them. In such a case, the object is defined by its ID, and in domain-driven design terms, it is considered an entity. This is a contrast to value objects that are defined by their properties, and are considered to be equal when their properties match. An entity is only ever equal if it has the same ID, even if all the properties match; as long as the ID is different, the entity is not the same.

Entity objects manage the lifecycle inside the application; this can either be the lifecycle ...

Get JavaScript Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.