Version 1 (modified by hauma, 15 years ago) (diff)

Starting point.

The Value Pattern

The Value pattern is a meta-pattern summarizing all approaches to express things in an object oriented language that are not first-class objects.

Besides encapsulated state that is accessed through the objet's methods, a first-class object has an identity. This identity is unique for each created object. It distinguishes an object from all other objects, no matter whether those objects are instances of the same class, or encapsulate exactly the same state.

In Java, two objects (object references) a and b are identical, if the (non-overloadable) operator == returns true for the comparision a == b. Another way how the identity of objects can be revealed, is their usage as locks in synchronization operations. Two variables refer to identical objects, if no concurrent access to regions synchronized (a) {...} and synchronized(b) {...} is granted.

Values do not (should not) have such identity. Two values are identical, if they behave equally. It makes no sense to use values locks in synchronization primitives.