Flexibility in Formats and Messages

An application suite needs a set of message formats that embraces the various purposes for which it sends messages. Nonetheless, the simplicity of a smaller set of formats usually yields optimal results.

When a format defines many possible fields, and a program sets only a few field values in a message, the message remains small, bearing only those fields that the program actually sets.

At one extreme, you can define a single catch-all format with all possible fields. Application programs can use as few or as many fields as is appropriate, without incurring a performance penalty.

When designing the set of formats for an application suite, balance these competing principles:

  • Specificity  Define as many formats as the application needs. If an application sends messages for different purposes, and the content structure of those messages is different, then define separate and specific formats for those messages.
  • Compactness  Defining a small number of formats is a good practice. A large set of formats is more difficult to understand, to configure, to use properly, and to maintain as your application evolves. If a subset of the formats are similar, and their usage or meanings are similar, then consider merging them into one format that contains a union of their fields.