liveBook · Manning

Factory

A factory is a function, method, class, or component that creates and returns objects or other values while encapsulating construction details or selection.

How 11 Manning books explain it

Unit Testing Principles, Practices, and Patterns

A factory is a creation abstraction that constructs domain objects from input data while encapsulating instantiation or reconstruction logic.

How it is used
Separates domain-object reconstruction from application-service coordination.
How deep it goes
Explains separate classes, static methods, ORM mappings, validation, casting, and test isolation, but not factory taxonomy.
Examples
Uses UserFactory.Create to transform an object array into a User and applies a three-element precondition.
What you can do after
Build it from scratch by isolating reconstruction, validating input, constructing domain objects, and keeping services focused on coordination.

Read how Unit Testing Principles, Practices, and Patterns explains factory →

Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

A factory module is a reusable infrastructure module that generates standardized infrastructure resources from inputs and default configuration values.

How it is used
Standardizes reusable infrastructure resources when repeated configurations share defaults but need limited input-driven variation.
How deep it goes
Explains inputs, defaults, transformations, naming, composition, and pattern selection, but leaves broader module sharing and security standardization elsewhere.
Examples
Demonstrates network subnets, generated names, GCP load balancers, firewall rules, database systems, and Python factory classes.
What you can do after
Build it from scratch by turning infrastructure inputs and defaults into standardized resources, then compose factories within builder modules.

Read how Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform explains factory →

The Art of Unit Testing 3e

A factory function is a function that creates and returns an object, value, or configured function.

How it is used
Centralizes test setup and dependency configuration so scenarios remain explicit while construction details stay reusable.
How deep it goes
Defines object-creating helpers and higher-order factories, then demonstrates configuration, closures, and maintenance consequences without advanced factory patterns.
Examples
Uses PasswordVerifier factories for passing rules, failing rules, time functions, loggers, constructor changes, and weekend behavior.
What you can do after
Apply it via JavaScript helper functions to centralize object or fake-dependency creation and localize setup changes.

Read how The Art of Unit Testing 3e explains factory →

Software Design for Python Programmers

A factory function is a function that encapsulates creating and returning objects, often selecting among subclass types based on an input value.

How it is used
Encapsulates runtime selection and creation of subclass objects behind a stable construction interface.
How deep it goes
Defines the principle, demonstrates a Python implementation, and extends it to Factory Method while stopping short of broader implementation detail.
Examples
Demonstrates toy cars, model airplanes, and train sets, then applies Factory Method to varsity and intramural sports.
What you can do after
Apply it via Python functions or classes to remove hardcoded construction and vary object types at runtime.

Read how Software Design for Python Programmers explains factory →

Object-Oriented Software Design in C++

A class responsible for creating and selecting instances of other classes while hiding construction details from clients.

How it is used
Encapsulates runtime selection and creation of subclass objects behind a shared interface.
How deep it goes
Explains parameterized factory functions and Factory Method delegation, but does not develop broader factory variants.
Examples
Uses ToyFactory with cars, airplanes, and trains, then AthleticsDept subclasses creating varsity and intramural sports.
What you can do after
Builds factory functions or subclass-based Factory Methods that select concrete objects while keeping clients stable.

Read how Object-Oriented Software Design in C++ explains factory →

Grokking Simplicity

A function factory is a function that creates and returns other functions, often with a shared behavior or configuration.

How it is used
Automates repeated function creation while standardizing cross-cutting behavior such as logging and error handling.
How deep it goes
Defines returned functions, wrappers, results, and argument handling, but defers broader variable-argument support to ES6 features.
Examples
Uses logging wrappers, saveUserData, fetchProduct, and makeAdder to demonstrate repeated creation and configured behavior.
What you can do after
Build reusable functions that apply consistent behavior to multiple underlying functions.

Read how Grokking Simplicity explains factory →

Essential TypeScript 5, Third Edition

A factory function is a function pattern that creates and returns objects or other configured values instead of requiring direct construction by the caller.

How it is used
Connects JSX syntax to runtime element creation and component rendering in a stand-alone web application.
How deep it goes
Explains compiler transformation and provides a minimal DOM implementation, but defers framework-level dynamic rendering features.
Examples
Uses createElement, HtmlDisplay, ProductItem, CategoryList, ProductList, DOM properties, nested components, and callbacks.
What you can do after
Build it from scratch with a createElement function that renders JSX into DOM elements and class-based components.

Read how Essential TypeScript 5, Third Edition explains factory →

ASP.NET Core in Action, 3e

A factory function is a function that creates and returns a configured object.

How it is used
Generalizes endpoint filters and configures dependency-injection service creation when runtime dependencies are needed.
How deep it goes
Explains endpoint inspection, filter emission, service lifetimes, and constructor-injection preference; defers endpoint metadata details.
Examples
Uses a fruit API’s ValidateId filter and lambda-created dependency-injection services as concrete examples.
What you can do after
Apply it via ASP.NET Core to tailor endpoint filters and create registered services with chosen lifetimes.

Read how ASP.NET Core in Action, 3e explains factory →

Fabulous Adventures in Data Structures and Algorithms

A factory is a construction pattern that centralizes creation of objects or data-structure instances.

How it is used
Uses factories to centralize memoized construction for immutable objects and deduplicate equivalent data structures.
How deep it goes
Builds the pattern through C# implementations, cache controls, reference identity, and memory trade-offs rather than general object-oriented taxonomy.
Examples
Demonstrates memoized functions, quadtrees, empty quadtree values, symbols, constants, and binary terms.
What you can do after
Build it from scratch using a dictionary-backed C# factory that caches immutable results and provides explicit cache control.

Read how Fabulous Adventures in Data Structures and Algorithms explains factory →

Build a Frontend Web Framework (From Scratch)

A function that creates and returns objects or other constructed values according to a defined creation procedure.

How it is used
Creates stateful component instances that localize state and DOM updates within a component hierarchy.
How deep it goes
Explains instantiation, state updates, view patching, and method binding, but does not provide production-level implementation details.
Examples
Uses a root component, component instances, local state, updateState(), render functions, and component DOM subtrees.
What you can do after
Build it from scratch by defining component state, rendering, updateState(), lifecycle behavior, and bound event handlers.

Read how Build a Frontend Web Framework (From Scratch) explains factory →

Data Pipelines with Apache Airflow, Second Edition

A factory function is a function that accepts configuration and constructs recurring workflow structures such as tasks or DAGs.

How it is used
Generates recurring Airflow task structures or DAGs from small configuration differences across related data sources.
How deep it goes
Explains configuration, task dependencies, DAG returns, and unique naming, but does not detail factory testing or deployment.
Examples
Uses sales and customers datasets, API ingestion, BashOperator tasks, dataset-specific paths, preprocessing scripts, and generated DAG names.
What you can do after
Build it from scratch by parameterizing repeated tasks or DAGs and exposing each generated DAG under a unique global name.

Read how Data Pipelines with Apache Airflow, Second Edition explains factory →

Related concepts

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.