Pipes and Filters

In one of its simplest forms, Pipes and Filters are available using a shell/console command line:

$ cat phone_numbers.txt | grep 303 | wc -l 3 $

Here a Linux command line is used to find how many contacts are in the fancy personal information manager, phone_numbers.txt, who have Colorado-based phone numbers. Admittedly this is not a very reliable way to implement that use case, but it does demonstrate how Pipes and Filters work:

1. The cat utility outputs the contents of phone_numbers.txt to what is called the standard output stream. Normally this stream is connected to the console. But when the | symbol is used, the output is piped to the input of the next utility.

2. Next, grep reads its input from the standard input stream, ...

Get Implementing Domain-Driven Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.