The DEAT Business Rule Pattern Language

Russell R. Hurlbut, Ph.D.

Previous | Table of Contents | Next

Rule Pattern 30: Type Conversion

Problem – Describing Semantically Meaningful Type Conversions

Many times one entity must be able to stand in for another entity. In such instances a type conversion is necessary that makes the stand-in appear to be of the same as the desired type.

Solution

Type conversions may be accomplished through declaration of type hierarchy mappings. The assumption of this business rule pattern is that some common shared ancestry between two types exists. Thus, all common attributes are compatible by type membership. Each of the remaining differences is decomposed until only primitive attribute types remain. A mapping between related attributes may be either one-to-one or one-to-many. Conversion algorithms are introduced if necessary by applying the Derivation Algorithm rule pattern.

In most cases a loss of information occurs, but the outcome may be sufficient for the intended purposes. For example, an attribute declared as a float loses precision if converted to an integer, but either representation may be sufficient for intended use in a calculation that would have rounded the number anyway. Therefore some measure of the tolerance of fidelity of the information can be indicated as part of the type conversion rule. If one considers image file formats, some formats such as PICT and TIFF are lossless representations of the original uncompressed bitmap. However, other compression formats make approximations for how the image is constructed, such as in the AVI and MPEG motion picture formats.

Example – Dual Use Real Estate

A residential property listed by a broker has a commercial zoning designation. In order to increase exposure and potential value, the broker markets the property as both a residential property and a commercial property. The source and target of the conversion and one of the attribute mappings is provided. The conversion expression may be expressed as a Derivation Algorithm rule pattern and reused in other contexts.

Dual Use Real Estate Parameters

Conversion Mapping Source

Residential

Conversion Mapping Target

Commercial

Mapping

Commercial.squareFootage = sum(room.length x room.width)

UML Representation and Related Patterns

The Type Conversion business rule pattern maps a Type model element. This pattern is closely related to the Type Migration business rule pattern.

Previous | Table of Contents | Next

 

Copyright 1998 Expertech.Ltd. All Rights Reserved.
 Legal