Initializer
An initializer is a function, declaration, or language construct that establishes the initial value or state of an object, value, computation, or process.
100 C++ Mistakes and How to Avoid Them
A constructor is a C++ member function that initializes an object when an instance of its class is created.
- How it is used
- Uses constructors to establish valid objects at creation and prevent partially initialized instances from entering client code.
- How deep it goes
- Explains initialization, validation, exceptions, duplication, and compiler-supplied members, while deferring detailed destructor and inheritance interactions.
- Examples
- Uses Person validation, Container defaulting and deletion, Complex in-class initialization, and Cylinder constructor deduplication.
- What you can do after
- Build it from scratch by defining initializing constructors, validating arguments, rejecting invalid state, and selecting defaulted or deleted members.
Read how 100 C++ Mistakes and How to Avoid Them explains initializer →
Web Components in Action
A constructor is a function or method invoked to initialize a newly created object of a particular class or type.
- How it is used
- Initializes custom-element state and establishes component structure before later lifecycle callbacks handle page-DOM interaction.
- How deep it goes
- Explains instantiation timing, inheritance, DOM restrictions, state setup, and Shadow DOM initialization, but not constructor internals.
- Examples
- Uses document.createElement(), custom-element alerts, property initialization, failed innerHTML assignment, and a Shadow DOM slider.
- What you can do after
- Build it from scratch by defining a custom-element constructor, calling super(), initializing state, and selecting the correct DOM lifecycle point.
100 Java Mistakes and How to Avoid Them
A constructor is a special Java member that initializes a newly created object and may throw exceptions or produce side effects.
- How it is used
- Prevents construction mistakes involving discarded objects, overloaded constructor references, and misleading StringBuilder initialization.
- How deep it goes
- Explains concrete failure modes and corrections, while deferring general constructor implementation internals.
- Examples
- Uses a discarded IllegalArgumentException, a computeIfAbsent StringBuilder factory, and a char-based StringBuilder call.
- What you can do after
- Diagnose/debug with it by spotting discarded constructions and unintended constructor-overload selection.
Read how 100 Java Mistakes and How to Avoid Them explains initializer →
The Joy of JavaScript
A callable JavaScript function intended to initialize a newly created object when invoked with construction semantics.
- How it is used
- Builds many similarly shaped JavaScript objects with different data while hiding initialization details from callers.
- How deep it goes
- Works through `new`, `this`, parent initialization, shared prototype methods, and missing-`new` guards; contrasts the resulting boilerplate with classes.
- Examples
- Uses `Transaction` and `HashTransaction` instances to compare duplicated methods, shared methods, and parent-field initialization.
- What you can do after
- Build it from scratch: initialize related objects with constructor functions and configure shared methods through prototypes.
Python How-To
A constructor is a callable that creates an instance of a class or other typed object.
- How it is used
- Creates instances of built-in containers and custom classes, including objects initialized with caller-supplied values.
- How deep it goes
- Explains class calls through the sequential roles of `__new__` and `__init__`, while noting that custom `__new__` implementations are usually unnecessary.
- Examples
- Uses task initialization, set construction, numeric-string conversion, and CSV rows converted to dictionaries.
- What you can do after
- Build it from scratch by defining `__init__`, and apply built-in constructors directly when their inputs already fit.
React Quickly, Second Edition
A constructor is a class method that runs when an instance is created and initializes its state or other instance data.
- How it is used
- Initializes component data once, including a stable gallery ID or a starting state value.
- How deep it goes
- Explains when constructors and state initializer functions run, with code examples, but defers changing state in response to props.
- Examples
- Uses a gallery image ID, counters with different starting values, a generated password, and function-valued calculator state.
- What you can do after
- Apply it via React constructors or useState initializer functions to keep initial values stable and avoid unnecessary calculations.
Read how React Quickly, Second Edition explains initializer →
Idiomatic Rust
A constructor is a conventional method or function that creates and returns a newly initialized value of a type.
- How it is used
- Creates initialized Rust values through a conventional associated function, usually named `new`.
- How deep it goes
- Works through empty and argument-taking struct initializers, then discusses naming and conversion alternatives; does not treat constructors as language machinery.
- Examples
- Shows `Pizza::new()` creating empty toppings and a revised `new(toppings: Vec<String>)` storing supplied toppings.
- What you can do after
- Build it from scratch as a `new` function returning `Self`, or choose `From` for a one-to-one conversion.
Modern C, Third Edition
An initializer is C syntax that supplies an initial value for an object declared in source code.
- How it is used
- Defines objects with known initial values and keeps program execution in a defined state when objects become visible.
- How deep it goes
- Explains scalar, aggregate, designated, default, incomplete-array, and storage-duration rules, but defers deeper initialization-function API details.
- Examples
- Uses scalar assignments, designated five-element arrays, incomplete arrays, and initialization functions for dynamically allocated rational values.
- What you can do after
- Apply initializers to define scalars and aggregates, select array elements explicitly, and choose initialization based on storage duration.
Kotlin in Action, 2E
A constructor is a Kotlin class member that initializes a new instance and receives constructor arguments.
- How it is used
- Initializes class instances and supplies constructor arguments, often declaring initialized properties in the primary constructor.
- How deep it goes
- Explains primary and secondary constructors, initializer blocks, defaults, named arguments, inheritance, visibility, and backing fields.
- Examples
- Uses User construction, Java-to-Kotlin Person conversion, superclass delegation, restricted constructors, and social-network initialization.
- What you can do after
- Build it from scratch with concise primary constructors, executable initializer blocks, alternate constructors, defaults, named arguments, and constructor delegation.
Related concepts
- iterableuses · An iterable is an object or value that provides or supports a protocol for producing its elements sequentially.
- default constructorincludes · A default constructor is a constructor that can be invoked without caller-supplied arguments, whether explicitly declared or implicitly provided by a language or compiler.
- special member functionkind of · A special member function is a C++ member function with compiler-recognized semantics for object initialization, copying, moving, or destruction.
- exceptionproduces · An exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
- primary constructorincludes · A primary constructor is the constructor declared in a Kotlin class header that specifies constructor parameters and can define properties initialized from them.
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.








