Previous Topic: Encapsulation OptionsNext Topic: Relationships


Attributes

The following sections describe the various types of attributes for an entity.

Derived

A derived attribute is one that is not stored. Derived attributes are the "attribute equivalent" of transient entity types and relationships. Developers may prefer to think of them as transient attributes.

Both persistent and transient entity types may own derived attributes. The attributes of a transient entity type must all be derived.

Persistent entity types may also own derived as well as persistent attributes. Derived attributes allow persistent types to display a degree of denormalization, without the need to store redundant data. For example, the Employee entity type may own the attributes Age and Boss's _Name. The first of these is derived from Date_Of_Birth, a persistent attribute of Employee; the second is derived from Head_Name, a persistent attribute of the associated entity type Department.

The consumer of an operation need not be concerned whether the attributes imported or exported by that operation are derived or persistent.

Protected

A protected attribute is one that is only visible to the implementations of the owning entity type. Attributes are protected so they can be altered, removed or added to the implementation of an entity type, without impacting the rest of the application. Ideally, encapsulated and restricted entity types protect all their persistent attributes, except for the primary identifier, since this enables consumers to have a "handle" on an occurrence of the entity type.

You should protect all non-derived attributes of restricted or encapsulated entity types, except for the primary identifier. This should enable the implementation of the entity type to be changed without impacting the consumers of the entity type.

Where the project is confident that a particular attribute is very stable, and it is very unlikely to be dropped or altered in any way, then the attribute may be unprotected to simplify the action diagramming. If the storage of the attribute is changed in future, the developer may alter the attribute to derived at that time, and introduce new persistent attributes to store the values.

Protected derived attributes may be used for attributes used in intermediate calculations, where there is no requirement to reveal this value to consumers.