liveBook · Manning

Positional collection

As explained in Data-Oriented Programming: Reduce software complexity

A positional collection is an ordered collection whose elements are accessed by their positions.

A positional collection keeps elements in order and retrieves them by position. Lists and arrays are typical examples; a positional collection of strings is written as [String]. section 3.1

Unlike an index, which retrieves values through keys such as ISBNs or author IDs, a positional collection represents ordered relationships directly. In a library model, a Book can store its authors as an ordered collection of author IDs. section 3.1

Choose the collection representation to fit the use case:

  • Use arrays when a simple positional representation is sufficient. section 3.2
  • Use linked lists, vectors, sets, or other collection types when their properties better suit the use case. section 3.2
  • Keep positional collections distinct from indexes: ordered access uses positions, while keyed access uses string maps. section 3.1

Authors in a Book record

A Book record may contain an authors field such as ["alan-moore", "dave-gibbons"]. The values preserve author order, while the IDs can be resolved through an author index. section 3.2 section 3.1

Figure 3.3 Library management relation model. Dashed lines (e.g., between Book and Author) denote indirect relations, [String] denotes a positional collection of strings, and {Book} denotes an index of Books.

Use the relation model to compare [String] positional collections with {Book} indexes and trace indirect Book–Author relationships. section 3.1

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Defines positional access, notation, and representation choices, but does not develop collection-specific implementation details.
Examples
Uses Book author IDs and Watchmen record arrays to demonstrate ordered collection representation.
What it assumes
Assumes basic collection knowledge while defining positional collections and contrasting them with keyed indexes.
What you can do after
Build it from scratch by selecting arrays or other collection types for ordered data relationships.
How it connects
Connects positional collections with indexes, records, data entity diagrams, and indirect associations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.