PoolObject
s can have attributes and properties assigned. Attributes are member variables stored with the object (flattened into the object storage). Properties are stored in property maps, external to the object.
Because they need to be flattened, attributes must be composed of primitive types and must always have the same size in memory. An example would be a double[3]
that stores a coordinate vector. In contrast, properties can have any type, for example a String
to store the name of an object.
Attributes can be assigned in the "constructor" (the init()
method) of a PoolObject
and therefore they can be effectively final. Properties are always initially unset and assigned after the PoolObject
has been constructed.
Properties, in contrast to attributes, can be used for non-PoolObjects
as well. The equivalent of an attribute for non-PoolObjects
is simply a member variable.