Descriptions, as we have seen in the above examples, are naturally organized in a description hierarchy. A class diagram of the most important descriptions is shown in Figure 164. Different kinds of descriptions exist: simple type-descriptions that directly map to Smalltalk classes, and some more advanced descriptions that are used to represent a collection of descriptions, or to model relationships between different entities.
Descriptions are central to Magritte and are connected to accessors and conditions that we present below.
- Type Descriptions. Most descriptions belong to this group, such as the
BooleanDescription, etc. All of them describe a specific Smalltalk class; in the examples given, this would be Color, Date, Number and all its subclasses, String, and Boolean and its two subclasses True and False. All descriptions know how to perform basic tasks on those types, such as to display, to parse, to serialize, to query, to edit, and to validate them.
- Container Descriptions. If a model object is described, it is often necessary to keep a set of other descriptions within a collection, for example the description of a person consists of a description of the title, the family name, the birthday, etc. The
ContainerDescriptionclass and its subclasses provide a collection container for other descriptions. In fact the container implements the whole collection interface, so that users can easily iterate (
do:), filter (
reject:), transform (
collect:) and query (
allSatisfy:) the containing descriptions.
- Option Descriptions. The
SingleOptionDescriptiondescribes an entity, for which it is possible to choose up to one item from a list of objects. The
MultipleOptionDescriptiondescribes a collection, for which it is possible to choose any number of items from a predefined list of objects. The selected items are described by the referencing description.
- Relationship Descriptions. Probably the most advanced descriptions are the ones that describe relationships between objects. The
ToOneRelationshipDescriptionmodels a one-to-one relationship; the
ToManyRelationshipDescriptionmodels a one-to-many relationship using a Smalltalk collection. In fact, these two descriptions can also be seen as basic type descriptions, since the
ToOneRelationshipDescriptiondescribes a generic object reference and the
ToManyRelationshipDescriptiondescribes a collection of object references.