liveBook · Manning

Composition

Also called Compose, composing

Composition is the construction of a larger behavior, computation, or system by combining smaller functions, components, or operations.

How 12 Manning books explain it

The Joy of JavaScript

A pipeline is a composition pattern where output from one stage becomes input to the next stage in sequence.

How it is used
Assembles small JavaScript functions into declarative business logic, including file word counts, hashing, and balance calculations.
How deep it goes
Defines execution order, implements compose2 and compose, and works through refactoring, currying, side effects, and point-free chains.
Examples
Uses string and file word counts, transaction hashing, and blockchain balance calculations as composed workflows.
What you can do after
Build it from scratch with compose2 and compose, then apply it to assemble reusable functions and separate pure transformations from file reading.

Read how The Joy of JavaScript explains composition →

Functional Programming in JavaScript

A sequence of function invocations linked by a shared intermediate value or by staged transformation.

How it is used
Builds modular JavaScript programs by joining small transformations into reusable operations.
How deep it goes
Explains compatibility, manual pipelines, compose implementation, and Ramda composition, while deferring static type systems.
Examples
Uses SSN cleanup and validation, word counting, student display, grade ranking, and Unix-style data processing.
What you can do after
Build it from scratch by composing compatible JavaScript functions with compose or Ramda's R.compose and R.pipe.

Read how Functional Programming in JavaScript explains composition →

Functional Programming in Scala, Second Edition

Kleisli composition is an operation that composes functions producing monadic results into a larger monadic computation.

How it is used
Assembles independent functions and stream transformations into reusable higher-level computations.
How deep it goes
Defines ordinary composition by types and implementation, then derives Kleisli composition as a view of monadic associativity.
Examples
Uses trigonometric functions, Option cases, and composed nonempty and lowercase stream pipes.
What you can do after
Build it from scratch by implementing ordinary and Kleisli compose, then combine stream transformations.

Read how Functional Programming in Scala, Second Edition explains composition →

Kubernetes for Developers

Object composition in Kubernetes is a pattern in which a higher-order resource embeds the specification of a lower-level resource.

How it is used
Uses embedded specifications to configure Pods managed by Deployments and Jobs, and Jobs scheduled by CronJobs.
How deep it goes
Explains template nesting through runnable manifests and controller behavior, while directing readers to API documentation for additional embedded fields.
Examples
Shows a standalone Pod, a one-off Job running a container command, and a CronJob scheduling that Job.
What you can do after
Build it from scratch by placing a PodSpec in a managed template and locating each setting at its proper nesting level.

Read how Kubernetes for Developers explains composition →

Write Powerful Rust Macros

Function composition combines functions so that the output of one becomes the input of another.

How it is used
Builds larger Rust behavior by chaining small functions through declarative or function-like macros.
How deep it goes
Works from typed two-function composition through recursive macro expansion and procedural parsing, without detailing the complete parser implementation.
Examples
Uses `add_one`, `stringify`, and `prefix_with` in comma-, arrow-, and dot-separated composition pipelines.
What you can do after
Build it from scratch with a generic `compose_two` closure and a recursive macro, or apply it through generated dot syntax.

Read how Write Powerful Rust Macros explains composition →

The Art of Code

Function composition is the construction of a function by chaining functions so that one function's output becomes the next function's input.

How it is used
Builds larger behavior by chaining small transformations whose outputs feed subsequent inputs.
How deep it goes
Defines chaining, demonstrates decomposition and Java andThen, and briefly contrasts language support without detailing implementation internals.
Examples
Uses field sanitization split into whitespace normalization and special-character removal, then composed with Java andThen.
What you can do after
Build it from scratch by splitting field sanitization into reusable transformations and composing them with Java’s andThen.

Read how The Art of Code explains composition →

Go by Example

Composition is a design approach that builds larger abstractions by combining smaller components rather than inheriting implementation from a base type.

How it is used
Builds reusable HTTP middleware, handlers, logging layers, and package APIs from focused pieces.
How deep it goes
Explains embedding, wrappers, higher-order functions, interfaces, assertions, and Context; defers detailed embedding treatment.
Examples
Uses response-recording and logging middleware around an HTTP health handler, with request logs and handler-chain flow.
What you can do after
Apply it via Go handlers and interfaces to extend behavior without modifying existing implementations.

Read how Go by Example explains composition →

Go in Action, Second Edition

Composition is a design technique that builds a type or object by combining independent components rather than deriving it through inheritance.

How it is used
Models domain types by combining simpler types rather than building inheritance hierarchies.
How deep it goes
Explains embedding and wrapper selection, but stops short of showing conversion method implementations.
Examples
Uses recipe measurements and imperial or metric wrappers to illustrate conversion behavior.
What you can do after
Build it from scratch by combining Go types and adding domain-specific behavior through methods.

Read how Go in Action, Second Edition explains composition →

F# in Action: A Revised Edition of Get Programming with F#

Function composition is the operation of combining functions so that the output of one function becomes the input of another.

How it is used
Uses composition to build reusable behavior from small functions and to chain HTTP handlers.
How deep it goes
Defines composition, contrasts it with pipelines, and demonstrates numeric and HTTP-handler examples without developing formal theory.
Examples
Shows adding and multiplying, filtering even numbers before squaring, and composing handlers for a device-status route.
What you can do after
Apply F#’s >> operator to combine functions whose output and input types match.

Read how F# in Action: A Revised Edition of Get Programming with F# explains composition →

Grokking Data Structures

Composition is a design technique that builds an object from instances of other objects rather than deriving it through inheritance.

How it is used
Uses composition to encapsulate reusable data-structure implementations behind focused class interfaces.
How deep it goes
Defines composition, shows constructors and delegated methods, and stops short of a detailed comparison of composition and inheritance.
Examples
Uses UnsortedArray wrapping Array and Bag delegating insertion and traversal to SinglyLinkedList.
What you can do after
Build it from scratch by wrapping an existing data structure and forwarding only the operations a new class should expose.

Read how Grokking Data Structures explains composition →

Learn Haskell by Example

Function composition is the construction of a function whose result is obtained by applying one function to the result of another.

How it is used
Uses composition to assemble concise CSV transformations and file-writing actions from partially applied functions.
How deep it goes
Defines operator order, demonstrates chaining and folding, and stops short of formal mathematical treatment.
Examples
Demonstrates arithmetic composition, CSV serialization, composed functions in lists, and folding composition across a function list.
What you can do after
Apply Haskell composition to construct compact transformation pipelines and CSV file writers.

Read how Learn Haskell by Example explains composition →

Deep Learning with PyTorch, Second Edition

The operation of applying one function to the output of another, used here to describe how layers are chained in a neural network.

How it is used
Explains how neural network layers are chained, with each layer’s output serving as the next layer’s input.
How deep it goes
Defines composition through sequential layer outputs and notes that matrix weights calculate across a layer.
Examples
Uses equations that pass each layer’s calculated output into the following layer.
What you can do after
Understand how outputs from successive neural network layers combine to produce a final output.

Read how Deep Learning with PyTorch, Second Edition explains composition →

Also covered in

What to know first

Related concepts

Questions about composition

What is composition?

Composition is the construction of a larger behavior, computation, or system by combining smaller functions, components, or operations.

Which Manning books explain composition?

The Joy of JavaScript, Functional Programming in JavaScript, Functional Programming in Scala, Second Edition, Kubernetes for Developers, Write Powerful Rust Macros, The Art of Code, Go by Example, Go in Action, Second Edition and 4 more.

What should I know before learning composition?

Manning books that teach composition usually introduce inheritance, object-oriented programming, class and function first.

What is the difference between composition and inheritance?

Composition is the construction of a larger behavior, computation, or system by combining smaller functions, components, or operations. Inheritance is a mechanism in which a derived type or descendant element receives properties or behavior from a parent, subject to rules that may allow specialization or overriding.

What is composition also called?

Composition is also called Compose or composing.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.