Data structures

A data structure is a way to organize information so a program can use it. The same ticket values can be organized in different ways, and each arrangement makes some operations easier than others.

The help desk now has several concrete requirements:

  • keep a bounded set of on-call slots;
  • append an open report to a growing log;
  • find a report by ID;
  • reject a repeated event;
  • take routine work in arrival order;
  • undo the latest update;
  • take urgent incidents first; and
  • follow connections between related reports.

There is no single structure that expresses all of these rules well. The structure should make the required operation and its correctness rule visible.

Case study checkpoint

The ticket record is still one value. We are deciding how to organize many values around the operations the system performs. A fixed array, a list, a dictionary, a set, a queue, a stack, a priority queue, and a graph may all hold ticket-related data, but they do not mean the same thing.

Keep the boundary between the event stream and its stored data clear.