4.11 Containment by Value Versus Containment by Reference
The last topic related to containment is a language-dependent distinction between containment by value and containment by reference. Containment by value implies that an object contains another object; containment by reference implies that an object contains a pointer to another object. Containment by value requires that an object lives and dies together with another object. Containment by reference allows for optional pieces of objects (a shrimp cocktail may or may not contain cocktail sauce), the sharing of one object by a group of other objects (i.e., object sharing), containment of an abstract class (e.g., meal contains appetizer), and the weak form of containment discussed above. Languages that do not distinguish between these two flavors of containment support containment by reference only. While this issue typically does not affect designers since they do not care about the particular implementation of a containment relationship, I mention it here since many case tools that are commercially available have icons that demonstrate the distinction. These case tools are more interested in the distinction because they need to generate C++ code than for any real architectural purpose (C++ allows for the explicit distinction between containment by value and containment by reference).