These are state objects (services)
These are value objects (structures) |
The essence of a state object is that new values may be assigned to its member variables again and again, and that two state objects are considered to be "equal" if they are identical, i.e., the same object. Copying/cloning a state object will normally contradict their "uniqueness semantics".
The essence of a value object is that its immediate and also its recursive constituent objects cannot be replaced by other objects any more as soon as the object leaves the "new" construct (which creates new objects of some specifiable class). In this sense, the object is frozen after creation.
Furthermore, comparing two value objects amounts to a recursive comparison of all their constituents.
If you don't want to completely freeze an entire object, including all its nested constituents, then you can specifically declare individual member objects of a Lava class to be "constant". Then only these members are protected against replacement by other objects.
Since Lava 0.9.1 we have modified the category notion in the following way:
Lava objects can be referenced only indirectly as values of Lava variables: Lava variables point to Lava objects, they are always of "reference type" as you would say in Eiffel or Java. Several variables may point to the same object. The data type of a Lava variable v is described by a Lava class, say A. The value of a Lava variable may be any object of class A (or a class derived from A).
The same Lava class may be used to declare variables of either category : state or value. The category is specified as part of Lava variable declarations. If a variable is declared to be of the "state object" category then a "~" (tilde) precedes the name of the variable in the Lava declaration tree and in the quantifiers/declare constructs where they are declared in executable code.
A variable may be
See also: Stages in the life of Lava objects (sample)
are special state objects that are dynamically created or static "inhabitants" of "components". Components are dynamically loadable software modules in which component objects may be activated/created that can communicate with other component objects over well-defined language-independent function-call interfaces.
See also: Lava as a component integration language
Persistent objects are component objects that can be "attached" by other components. It is expected that they exist already at this time, although they may exist in a deactivated state and thus must be activated before they are attached. In Lava, databases are treated as special persistent objects.
Value objects ... | State objects ... |
... are frozen after completion | ... can be changed again and again even after completion |
... serve, e.g., as messages exchanged between and as member objects of state objects | ... provide continuous services |
Equal relation ("=") compares values ("equality semantics") | Equal relation ("=") compares pointers ("identity semantics") |
... are passed by value between, by reference within components | ... are always passed by reference |
... can be persistent only as constituents of component objects | ... can be persistent component objects |
Their member objects are usually accessed directly | Their member objects are usually accessed via set/get functions, those of component objects always |