Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistent and transient objects - confused about terminology

Here is my definition of the two terms, though I'm not sure if it is a complete one:

A persistent object is an instance of a class in the domain model that represents some information extracted from the database. A transient object is an instance of a class in the domain model, which is created in memory

a) I assume the terms persistent and transient are used only for objects in the domain model, but not also for objects in business layer that live outside the domain model?

b) Do we also use the two terms for Data-Transfer-Objects?

c) Are the two terms also used for Value Objects?

Thank you

like image 557
user1483278 Avatar asked Jul 12 '12 18:07

user1483278


1 Answers

Persistent means that the object has been saved to the database whereas transient means that it hasn't been saved yet. So for example when you get an entity from a repository, that entity is persistent. When you create a new entity, it is transient until persisted.

a) These terms are more affiliated with ORMs than they are with DDD so they apply to anything that is not DDD. Within DDD persisted/transient apply to entities and aggregate roots because these are the objects that are persisted with repositories.

b) No, DTOs are designed to carry data across process boundaries and don't have a life-cycle that objects that you wish to persist to a database do.

c) No because value objects don't have an identity and can only be persisted as part of an entity or aggregate root. A value object is just a value, sort like 1 is a integer value and it doesn't make sense to speak about whether it is persisted or not.

like image 140
eulerfx Avatar answered Oct 04 '22 15:10

eulerfx