Dynamic Web Development with Seaside

26.3Descriptions

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.

Description hierarchy

Descriptions are central to Magritte and are connected to accessors and conditions that we present below.

Descriptions are a composite and connected via accessors

  1. Type Descriptions. Most descriptions belong to this group, such as the ColorDescription, the DateDescription, the NumberDescription, the StringDescription, 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.
  2. 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 ContainerDescription class 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 (select:, reject:), transform (collect:) and query (detect:, anySatisfy:, allSatisfy:) the containing descriptions.
  3. Option Descriptions. The SingleOptionDescription describes an entity, for which it is possible to choose up to one item from a list of objects. The MultipleOptionDescription describes 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.
  4. Relationship Descriptions. Probably the most advanced descriptions are the ones that describe relationships between objects. The ToOneRelationshipDescription models a one-to-one relationship; the ToManyRelationshipDescription models a one-to-many relationship using a Smalltalk collection. In fact, these two descriptions can also be seen as basic type descriptions, since the ToOneRelationshipDescription describes a generic object reference and the ToManyRelationshipDescription describes a collection of object references.

Copyright © 19 March 2024 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.