Factory
A factory is a function, method, class, or component that creates and returns objects or other values while encapsulating construction details or selection.
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.
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.
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.
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.
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
- inputuses · An input is a value, information, or signal supplied to a system, computation, or interface for processing or to influence its behavior.
- const qualifieruses · A const qualifier is a language feature that restricts modification or reassignment of a value or binding according to the language’s rules.
- infrastructure resourceproduces · An infrastructure resource is an identifiable supporting component or service that provides technical capabilities on which applications or other system components depend.
- functionkind of · A function is a defined operation that maps inputs to outputs and, when implemented as a callable program unit, may also produce effects.
- design patternkind of · A design pattern is a reusable, general solution structure for a recurring software design problem in a particular context.
- hardcodingaddresses · Hardcoding is embedding fixed values, rules, configuration, or behavioral choices directly in a program or its implementation rather than supplying or deriving them separately.
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.










