Assignment by Value and by Reference
Assignments can be made either by reference or by value. For an assignment by reference, the entity to which the assignment is made refers to the entity being assigned. In other words, subsequent changes to the entity by either the new or existing reference is reflected in both places (there is only one entity; it isn’t copied). However, for a by value assignment, a copy of the assigned entity is made, and that is what is applied to the entity receiving the assignment. This results in two independent objects. Therefore, changes in one place do not affect the other.
Assignment to... | ...of type... | ...behaves as follows: |
---|---|---|
Business Object attribute or composition | BOM Native or Primitive Type | Effectively by value.
For efficiency’s sake, objects are only copied where they are mutable (where their internal value can be changed). In other words, by reference behavior is sometimes used, but always behaves like by value. See BOM Native Type or Primitive Type Object to Business Object Attribute . |
BOM Class | By reference.
Important note: If the BOM Object being assigned is already contained by another BOM object’s containment, it will be removed from that containment automatically because it is impossible for an object to be contained by two containers at the same time. If this is not the desired behavior, make a copy of the object first. See Assigning a Business Object . |
|
Process Data Field | BOM Class | By reference. See Assigning a Business Object . |
Basic Type | By value. See Assigning a Basic Type Object to a Process Data Field . |