Understanding queues as interfaces
In our two recent example-programs, we’ve seen how tasks, queues, and stream-buffers can be used to create well-structured designs for processing serial data streams. These designs, and their code, can be reused, as they are applicable to other serial data streams, with similar data structures and processing requirements.
Let’s take a look at why using queues is a good idea. The concepts are applicable to similar data structures, such as stream-buffers:
- Queues make excellent interface definitions: Queues provide a very clear line of abstraction. To pass data through a queue and get a desired behavior on the other side, all of the needed data must be present. And, the sender and receiver must both have a common understanding of what the data format is. This clean line forces a level of conscientious thought as to what exactly needs to be communicated. Sometimes, this level of active thought isn’t present when implementing...