Reputation: 949
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
Upvotes: 10
Views: 30329
Reputation: 1
An object typically has two components: state (value) and behavior (operations).It can have a complex data structure as well as specific operations defined by the programmer.9 Objects in an OOPL exist only during program execution; therefore, they are called transient objects. An OO database can extend the existence of objects so that they are stored permanently in a database, and hence the objects become persistent objects that exist beyond program termination and can be retrieved later and shared by other programs. In other words, OO databases store persistent objects permanently in secondary storage, and allow the sharing of these objects among multiple programs and applications.
Upvotes: 0
Reputation: 1
Transient means unprocessed object or the object which is instantiated or newly created. Once the object is being submitting for any other operation than the object state is known an persistent
Upvotes: 0
Reputation: 37739
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.
Upvotes: 23