O'Reilly logo

Implementing Domain-Driven Design by Vaughn Vernon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When the Timing of Identity Generation Matters

Identity generation can occur either early, as part of the object’s construction, or late, as part of its persistence. Sometimes it’s important to time identity generation early, and other times not. If it matters, we need to understand what’s involved.

Consider possibly the simplest case, that we can tolerate the late allocation of identity when a new Entity is persisted, that is, a new row is inserted in the database. This is demonstrated in the diagram in Figure 5.3. The client just instantiates a new Product and adds it to the ProductRepository. When the Product instance is newly created, the client doesn’t need its identity. And it’s a good thing, too, because the identity won’t exist then. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required