liveBook · Manning

Pipeline

As explained in The Art of Code

A pipeline is a composable sequence of data-processing stages in which intermediate operations define transformations and a terminal operation executes them.

A pipeline tells a data-processing story: data enters, each stage transforms it, and a final operation produces a result. It separates data from behavior, replacing control-flow detail with a readable sequence of named transformations. section 6.3 section 6.5

Figure 6.2 A functional pipeline: transforming raw data
figure

View a pipeline as data flowing through behavioral stages, like raw material being filtered and reshaped before it reaches an output. section 6.3

Build a pipeline in three parts:

  • Creation: expose a data source through a structure that can apply transformations step by step. section 6.3.1
  • Intermediate operations: add lazy steps such as filter, map, or flatMap; they define behavior but process no data yet. section 6.3.1 section 6.5
  • Terminal operation: trigger execution and materialize a result with operations such as toList, collect, or count. A Java stream is then consumed and cannot be reused. section 6.3.1 section 6.5

Recent authors

Start with books, filter to those published within the last year, map each remaining Book to its author, then collect the names. The chain reads top-down as intent: select recent books, extract authors, make a list. Java streams, Kotlin sequences, C# LINQ, Python generator expressions, and Haskell can express comparable flows with different syntax. section 6.3.1

Keep a pipeline short enough to understand as a whole. Each operation is a chunk of logic; once a chain becomes a riddle, group related filters, extract well-named methods, or store an intermediate result and continue in a second stage. section 6.3.3 section 6.5

Do not force every task into a pipeline. File access, database updates, network messages, mutation-heavy algorithms, and exception-prone operations can make an imperative approach clearer. Prefer pipelines when composition makes the flow explicit; keep any impurity visible. section 6.3.2 section 6.4

How The Art of Code covers it

How deep it goes
Defines creation, lazy intermediate operations, terminal execution, consumption, exception tradeoffs, and readability refactoring without stream implementation internals.
Examples
Uses recent-book author extraction, file-line flattening, email sanitization, and a constrained youngest-oldest-name exercise.
What it assumes
Assumes familiarity with functions and applies Java collections, streams, predicates, functions, and method references.
What you can do after
Apply it via Java streams to compose lazy transformations, trigger results, and simplify overly long chains.
How it connects
Connects pipelines with functional programming, pure functions, lambdas, functional interfaces, lazy evaluation, exceptions, and imperative programming.

Also explained in

Compare how 48 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.