Programming Search⌘K

Patterncore

Static factory method

Also called static factory, named constructor, named constructor idiom, factory function, alternative constructor.

A class gives a static method that returns an instance, in place of a public constructor. The method has a name, can return a cached object, a subtype, or no object.

Family
creational-design
Intent
Give a class static methods that return its instances, so that each way to create an object has a name, and the class controls which object the caller gets.
Also called
Named Constructor

Intent

Give a class static methods that return its instances. Each way to create an object then has a name, and the class controls which object the caller gets: a new one, a cached one, or an object of a subclass.1

Problem

A class Duration holds a length of time in seconds. Callers want to create it from seconds, from minutes, and from a text such as "2m". Most durations in a program are zero, so the class could give the same zero object to every caller. A text such as "2h" is not valid, and the caller must learn this without a crash.

A constructor meets none of these needs. In Java, C# and C++, every constructor has the name of the class. Two constructors cannot both take one long, so "from seconds" and "from minutes" cannot both be constructors. A constructor always creates a new object, and the object is always of exactly that class. A constructor cannot return "no object". It can only throw.

JavaScript shows the cost of an unnamed constructor. Array.of(7) creates an array with the single element 7, but Array(7) creates an empty array with a length of 7.2 The reader of Array(7) must know the rule for one argument. The reader of Array.of(7) does not.

Solution

Make the constructor private, or at least not the main way in. Add static methods that call it. Each method has a name that says what the arguments mean, and each method decides what to return.1

 Client                         Duration
 ------                         ------------------------------------
 Duration.ofMinutes(2) -------> ofMinutes(m) = ofSeconds(m * 60)
 Duration.ofSeconds(0) -------> ofSeconds(s):
                                    if s == 0: return ZERO   (cached)
                                    return new Duration(s)   (private)
 Duration.parse("2h")  -------> parse(text): Duration or empty

There are two participants. The product is the class, with a private constructor. The factory methods are static methods of the same class, or functions in the same module. The client calls a method by name and gets the product.

Bloch gave this advice as Item 1 of the first edition of Effective Java in 2001,3 and the third edition keeps it as Item 1. The third edition gives five advantages over a public constructor:1

  1. A factory method has a name. ofSeconds and ofMinutes take the same parameter type and still both exist.
  2. It need not create a new object on each call. It can return a cached instance, as ofSeconds(0) does.
  3. It can return an object of any subtype of its declared return type, so the class of the result can stay hidden.
  4. The class of the result can change from call to call, as a function of the arguments.
  5. The class of the result need not exist when the factory method is written. Service provider frameworks use this.

Item 1 also lists the common names: from for a conversion, of for an aggregation, valueOf, instance or getInstance, create or newInstance, and the forms getType, newType and type when the method is in another class.1 Other languages have their own conventions. In Rust, the main constructor is usually named new, other constructors get a suffix such as _with_foo, and conversion constructors start with from_.4 In Go, a function named New or NewT plays the part, as ring.New does.5

Example

The example files show one program in each language. Duration has a factory method from seconds, one from minutes, and one that parses a text. The zero duration is cached, and a bad text gives "no object" in place of a crash:

Language Form
Python classmethod factories that call cls(...)6
JavaScript static methods; a private Symbol guards the constructor
TypeScript a private constructor and static methods
Java a private constructor, static methods and Optional
C# a private constructor, static methods and a TryParse method
C++ a private constructor, static member functions and std::optional
Go package-level functions; a parse function that returns an error
Rust associated functions with no self; parse returns a Result4
PythonGitHub
class Duration:
    """A length of time in whole seconds. Create it with a factory method."""

    _zero = None

    def __init__(self, seconds: int):
        self.seconds = seconds

    @classmethod
    def of_seconds(cls, seconds: int) -> "Duration":
        if seconds == 0:
            if cls._zero is None:
                cls._zero = cls(0)
            return cls._zero  # the same instance every time
        return cls(seconds)

    @classmethod
    def of_minutes(cls, minutes: int) -> "Duration":
        return cls.of_seconds(minutes * 60)

    @classmethod
    def parse(cls, text: str) -> "Duration | None":
        units = {"s": 1, "m": 60}
        number, unit = text[:-1], text[-1:]
        if unit not in units or not number.isdigit():
            return None  # a constructor cannot return "no object"
        return cls.of_seconds(int(number) * units[unit])

    def __str__(self) -> str:
        return f"{self.seconds} s"


print("of_minutes(2) =", Duration.of_minutes(2))
print("of_seconds(90) =", Duration.of_seconds(90))
print("zero is cached:", Duration.of_seconds(0) is Duration.of_minutes(0))
print('parse("2m") =', Duration.parse("2m"))
print('parse("2h") =', Duration.parse("2h"))
Output
of_minutes(2) = 120 s
of_seconds(90) = 90 s
zero is cached: True
parse("2m") = 120 s
parse("2h") = None
  • Verdict: idiom. Python has one __init__ for each class, so a second way to build an object is a classmethod. The standard library uses the form in dict.fromkeys and datetime.date.fromtimestamp.
  • A class method gets the class as its first argument, so cls(...) builds an instance of the subclass when a subclass calls it. A staticmethod that names Duration would not.
  • Python cannot make __init__ private. The factory method is the documented way, and the constructor stays public.
#include <iostream>
#include <memory>
#include <optional>
#include <string>

class Duration {
public:
    static std::shared_ptr<const Duration> of_seconds(long seconds) {
        static const auto zero = std::shared_ptr<const Duration>(new Duration(0));
        if (seconds == 0) return zero;  // the same instance every time
        return std::shared_ptr<const Duration>(new Duration(seconds));
    }

    static std::shared_ptr<const Duration> of_minutes(long minutes) {
        return of_seconds(minutes * 60);
    }

    static std::optional<std::shared_ptr<const Duration>> parse(const std::string& text) {
        if (text.size() < 2) return std::nullopt;
        char unit = text.back();
        std::string number = text.substr(0, text.size() - 1);
        if ((unit != 's' && unit != 'm') ||
            number.find_first_not_of("0123456789") != std::string::npos) {
            return std::nullopt;  // a constructor cannot return "no object"
        }
        long n = std::stol(number);
        return of_seconds(unit == 'm' ? n * 60 : n);
    }

    std::string str() const { return std::to_string(seconds_) + " s"; }

private:
    explicit Duration(long seconds) : seconds_(seconds) {}
    long seconds_;
};

int main() {
    std::cout << "of_minutes(2) = " << Duration::of_minutes(2)->str() << "\n";
    std::cout << "of_seconds(90) = " << Duration::of_seconds(90)->str() << "\n";
    std::cout << std::boolalpha << "zero is cached: "
              << (Duration::of_seconds(0) == Duration::of_minutes(0)) << "\n";
    auto a = Duration::parse("2m");
    std::cout << "parse(\"2m\") = " << (a ? (*a)->str() : "nullopt") << "\n";
    auto b = Duration::parse("2h");
    std::cout << "parse(\"2h\") = " << (b ? (*b)->str() : "nullopt") << "\n";
}
Output
of_minutes(2) = 120 s
of_seconds(90) = 90 s
zero is cached: true
parse("2m") = 120 s
parse("2h") = nullopt
  • Verdict: idiom, often called the named constructor idiom. The constructor is private, and static member functions build the object.
  • A shared instance needs shared ownership, so the factory returns std::shared_ptr<const Duration>. A factory that always makes a new object would return the value or a std::unique_ptr.
  • std::make_shared cannot call a private constructor, so the example calls new inside the class.
JavaGitHub
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    static final class Duration {
        private static final Duration ZERO = new Duration(0);
        private static final Pattern TEXT = Pattern.compile("(\\d+)([sm])");
        private final long seconds;

        private Duration(long seconds) { // only the factory methods call it
            this.seconds = seconds;
        }

        static Duration ofSeconds(long seconds) {
            return seconds == 0 ? ZERO : new Duration(seconds); // a cached instance
        }

        static Duration ofMinutes(long minutes) {
            return ofSeconds(minutes * 60);
        }

        static Optional<Duration> parse(String text) {
            Matcher m = TEXT.matcher(text);
            if (!m.matches()) {
                return Optional.empty(); // a constructor cannot return "no object"
            }
            long n = Long.parseLong(m.group(1));
            return Optional.of(ofSeconds(m.group(2).equals("m") ? n * 60 : n));
        }

        @Override
        public String toString() {
            return seconds + " s";
        }
    }

    public static void main(String[] args) {
        System.out.println("ofMinutes(2) = " + Duration.ofMinutes(2));
        System.out.println("ofSeconds(90) = " + Duration.ofSeconds(90));
        System.out.println("zero is cached: " + (Duration.ofSeconds(0) == Duration.ofMinutes(0)));
        System.out.println("parse(\"2m\") = " + Duration.parse("2m").map(Duration::toString).orElse("empty"));
        System.out.println("parse(\"2h\") = " + Duration.parse("2h").map(Duration::toString).orElse("empty"));
    }
}
Output
ofMinutes(2) = 120 s
ofSeconds(90) = 90 s
zero is cached: true
parse("2m") = 120 s
parse("2h") = empty
  • Verdict: idiom. This is the form of Effective Java Item 1: a private constructor and static methods with names such as of, from and valueOf.
  • java.time.Duration has the same design: ofSeconds and ofMinutes are static methods, and a zero length returns the constant Duration.ZERO.
  • Two constructors with the parameter list (long) cannot exist in one class. Two static methods with different names can.
using System;
using System.Text.RegularExpressions;

sealed class Duration
{
    private static readonly Duration Zero = new Duration(0);
    private readonly long seconds;

    private Duration(long seconds) => this.seconds = seconds;

    public static Duration OfSeconds(long seconds) =>
        seconds == 0 ? Zero : new Duration(seconds); // a cached instance

    public static Duration OfMinutes(long minutes) => OfSeconds(minutes * 60);

    public static bool TryParse(string text, out Duration? result)
    {
        Match m = Regex.Match(text, @"^(\d+)([sm])$");
        if (!m.Success)
        {
            result = null; // a constructor cannot report "no object"
            return false;
        }
        long n = long.Parse(m.Groups[1].Value);
        result = OfSeconds(m.Groups[2].Value == "m" ? n * 60 : n);
        return true;
    }

    public override string ToString() => $"{seconds} s";
}

static class Program
{
    static void Main()
    {
        Console.WriteLine($"OfMinutes(2) = {Duration.OfMinutes(2)}");
        Console.WriteLine($"OfSeconds(90) = {Duration.OfSeconds(90)}");
        Console.WriteLine($"zero is cached: {ReferenceEquals(Duration.OfSeconds(0), Duration.OfMinutes(0))}");
        Console.WriteLine($"TryParse(\"2m\") = {(Duration.TryParse("2m", out var a) ? a : "failed")}");
        Console.WriteLine($"TryParse(\"2h\") = {(Duration.TryParse("2h", out var b) ? b : "failed")}");
    }
}
Output
OfMinutes(2) = 120 s
OfSeconds(90) = 90 s
zero is cached: True
TryParse("2m") = 120 s
TryParse("2h") = failed
  • Verdict: idiom. A private constructor and public static methods. TimeSpan.FromSeconds and TimeSpan.FromMinutes in .NET have the same shape.
  • The TryParse form returns bool and gives the object through an out parameter. It is the .NET convention for a factory that can fail without an exception.
JavaScriptGitHub
class Duration {
  static #zero = null;
  static #token = Symbol("Duration");
  #seconds;

  constructor(seconds, token) {
    if (token !== Duration.#token) {
      throw new TypeError("use Duration.ofSeconds or Duration.ofMinutes");
    }
    this.#seconds = seconds;
  }

  static ofSeconds(seconds) {
    if (seconds === 0) {
      Duration.#zero ??= new Duration(0, Duration.#token);
      return Duration.#zero; // the same instance every time
    }
    return new Duration(seconds, Duration.#token);
  }

  static ofMinutes(minutes) {
    return Duration.ofSeconds(minutes * 60);
  }

  static parse(text) {
    const m = /^(\d+)([sm])$/.exec(text);
    if (m === null) return null; // a constructor cannot return "no object"
    return Duration.ofSeconds(Number(m[1]) * (m[2] === "m" ? 60 : 1));
  }

  toString() {
    return `${this.#seconds} s`;
  }
}

console.log(`ofMinutes(2) = ${Duration.ofMinutes(2)}`);
console.log(`ofSeconds(90) = ${Duration.ofSeconds(90)}`);
console.log(`zero is cached: ${Duration.ofSeconds(0) === Duration.ofMinutes(0)}`);
console.log(`parse("2m") = ${Duration.parse("2m")}`);
console.log(`parse("2h") = ${Duration.parse("2h")}`);
try {
  new Duration(5);
} catch (e) {
  console.log(`new Duration(5): ${e.constructor.name}`);
}
Output
ofMinutes(2) = 120 s
ofSeconds(90) = 90 s
zero is cached: true
parse("2m") = 120 s
parse("2h") = null
new Duration(5): TypeError
  • Verdict: idiom. A JavaScript class has one constructor, and the language has no private constructors. The factory methods are static methods.
  • The example hides the constructor with a private Symbol that only the class can pass. Most code does not do this, and documents the factory methods instead.
  • The standard library uses the form: Array.of(7) makes [7], but Array(7) makes an empty array of length 7. The name removes the doubt about one argument.
TypeScriptGitHub
class Duration {
  private static zero: Duration | null = null;

  private readonly seconds: number;

  private constructor(seconds: number) {
    this.seconds = seconds;
  }

  static ofSeconds(seconds: number): Duration {
    if (seconds === 0) {
      Duration.zero ??= new Duration(0);
      return Duration.zero; // the same instance every time
    }
    return new Duration(seconds);
  }

  static ofMinutes(minutes: number): Duration {
    return Duration.ofSeconds(minutes * 60);
  }

  static parse(text: string): Duration | null {
    const m = /^(\d+)([sm])$/.exec(text);
    if (m === null) return null; // a constructor cannot return "no object"
    return Duration.ofSeconds(Number(m[1]) * (m[2] === "m" ? 60 : 1));
  }

  toString(): string {
    return `${this.seconds} s`;
  }
}

console.log(`ofMinutes(2) = ${Duration.ofMinutes(2)}`);
console.log(`ofSeconds(90) = ${Duration.ofSeconds(90)}`);
console.log(`zero is cached: ${Duration.ofSeconds(0) === Duration.ofMinutes(0)}`);
console.log(`parse("2m") = ${Duration.parse("2m")}`);
console.log(`parse("2h") = ${Duration.parse("2h")}`);
// new Duration(5) is a compile error: the constructor is private.
Output
ofMinutes(2) = 120 s
ofSeconds(90) = 90 s
zero is cached: true
parse("2m") = 120 s
parse("2h") = null
  • Verdict: idiom. TypeScript allows a private constructor, so the compiler rejects new Duration(5) outside the class. Only the static methods can build an instance.
  • The check is at compile time only. The JavaScript that the compiler emits has a normal constructor.
package main

import (
	"fmt"
	"regexp"
	"strconv"
)

// Duration has an unexported field, so other packages build it only
// through the functions below.
type Duration struct {
	seconds int64
}

var zero = &Duration{0}

func OfSeconds(seconds int64) *Duration {
	if seconds == 0 {
		return zero // the same instance every time
	}
	return &Duration{seconds}
}

func OfMinutes(minutes int64) *Duration {
	return OfSeconds(minutes * 60)
}

var text = regexp.MustCompile(`^(\d+)([sm])$`)

func Parse(s string) (*Duration, error) {
	m := text.FindStringSubmatch(s)
	if m == nil {
		return nil, fmt.Errorf("bad duration %q", s)
	}
	n, _ := strconv.ParseInt(m[1], 10, 64)
	if m[2] == "m" {
		n *= 60
	}
	return OfSeconds(n), nil
}

func (d *Duration) String() string { return fmt.Sprintf("%d s", d.seconds) }

func main() {
	fmt.Println("OfMinutes(2) =", OfMinutes(2))
	fmt.Println("OfSeconds(90) =", OfSeconds(90))
	fmt.Println("zero is cached:", OfSeconds(0) == OfMinutes(0))
	d, err := Parse("2m")
	fmt.Println(`Parse("2m") =`, d, err)
	d, err = Parse("2h")
	fmt.Println(`Parse("2h") =`, d, err)
}
Output
OfMinutes(2) = 120 s
OfSeconds(90) = 90 s
zero is cached: true
Parse("2m") = 120 s <nil>
Parse("2h") = <nil> bad duration "2h"
  • Verdict: idiom. Go has no constructors. A package-level function, by convention named New or NewT, builds the value, as ring.New and os.NewFile do.
  • The function is not a method of the type, so the name says the type: OfSeconds here, or time.ParseDuration in the standard library.
  • A Go factory that can fail returns a second result of type error.
RustGitHub
use std::fmt;
use std::rc::Rc;

pub struct Duration {
    seconds: u64, // private, so other modules must use the functions below
}

thread_local! {
    static ZERO: Rc<Duration> = Rc::new(Duration { seconds: 0 });
}

impl Duration {
    pub fn from_secs(seconds: u64) -> Rc<Duration> {
        if seconds == 0 {
            return ZERO.with(Rc::clone); // the same instance every time
        }
        Rc::new(Duration { seconds })
    }

    pub fn from_mins(minutes: u64) -> Rc<Duration> {
        Duration::from_secs(minutes * 60)
    }

    pub fn parse(text: &str) -> Result<Rc<Duration>, String> {
        let (number, unit) = text.split_at(text.len().saturating_sub(1));
        let n: u64 = number.parse().map_err(|_| format!("bad number in {text:?}"))?;
        match unit {
            "s" => Ok(Duration::from_secs(n)),
            "m" => Ok(Duration::from_mins(n)),
            _ => Err(format!("bad unit in {text:?}")),
        }
    }
}

impl fmt::Display for Duration {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{} s", self.seconds)
    }
}

fn main() {
    println!("from_mins(2) = {}", Duration::from_mins(2));
    println!("from_secs(90) = {}", Duration::from_secs(90));
    println!("zero is cached: {}", Rc::ptr_eq(&Duration::from_secs(0), &Duration::from_mins(0)));
    match Duration::parse("2m") {
        Ok(d) => println!("parse(\"2m\") = {d}"),
        Err(e) => println!("parse(\"2m\") failed: {e}"),
    }
    match Duration::parse("2h") {
        Ok(d) => println!("parse(\"2h\") = {d}"),
        Err(e) => println!("parse(\"2h\") failed: {e}"),
    }
}
Output
from_mins(2) = 120 s
from_secs(90) = 90 s
zero is cached: true
parse("2m") = 120 s
parse("2h") failed: bad unit in "2h"
  • Verdict: idiom. Rust has no constructors in the language. The API Guidelines say that constructors are static, inherent methods, and new is the usual name of the main one.
  • Other names follow the same rule: with_capacity, from_secs, from_raw_os_error. std::time::Duration::from_secs is the standard version of this example.
  • A struct with a private field cannot be built with a struct literal in another module, so the functions are the only way in.
  • A small value is usually returned by value. The example returns Rc<Duration> only to show that a factory can return a shared instance.

Consequences

The benefits are the five advantages of the Solution. Two of them have a cost that a caller must know.

A cached instance changes the meaning of ==. When a factory method returns a cached object, two calls can give the same object, and an identity test is true. When it does not, the test is false. Integer.valueOf caches some values. Its documentation says that it "will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range."7 Code that compares with == then works for small numbers only:

This code runs but gives a wrong answer on purpose.

public class Main {
    public static void main(String[] args) {
        Integer a = Integer.valueOf(127);
        Integer b = Integer.valueOf(127);
        Integer c = Integer.valueOf(1000);
        Integer d = Integer.valueOf(1000);
        System.out.println(a == b);      // the same cached object
        System.out.println(c == d);      // two objects with the default settings
        System.out.println(c.equals(d)); // the correct test
    }
}
Output
true
false
true

The result of the second line is not fixed by the API, because a JVM may cache more values. Compare values with equals, and treat a cached instance as an optimization that callers must not see.

The class of the result can vary. EnumSet.noneOf returns a RegularEnumSet when the enum has at most 64 constants, and a JumboEnumSet when it has more.8 Callers see only EnumSet, so the library can add a third class later. The same freedom is a trap for a caller that tests the concrete class or casts to it.

The costs, from Item 1:1

  • A class with no public or protected constructor cannot be subclassed. Bloch notes that this can be a benefit, because it pushes users to composition.
  • A factory method is harder to find than a constructor. API documentation lists constructors in their own section, but a factory method is one static method among many. The naming conventions above reduce this cost.

A static factory method is not the Factory Method pattern. The Factory Method of Design Patterns is an instance method that a subclass overrides, so that a base class can create an object whose class it does not know.9 A static method cannot be overridden. It chooses the class itself, from its arguments. Bloch makes the same point: a static factory method has no direct equivalent in Design Patterns.1 See Factory Method pattern for the other pattern.

When not to use it

Do not add a factory method when one public constructor is clear. A record or a data class with two fields gains nothing from Point.of(x, y) that new Point(x, y) does not give.

Do not give a factory method the name of the class without a reason. The Kotlin conventions ask for a distinct name that makes clear why the factory is special, and allow the class name only when there are no special semantics.10

Do not use many factory methods for many optional parameters. Ten methods for ten combinations are as hard to read as ten constructors. The Rust API Guidelines point to a builder when a type has a multiplicity of construction options.4 See Builder pattern.

Do not hide a public constructor that callers already use. A new factory method can sit next to it. Java deprecated the constructor Integer(int) and kept it. Its documentation says that the static factory valueOf(int) is generally a better choice.7

Class methods. In Python, a classmethod receives the class as its first argument. When a subclass calls the method, the subclass is passed.6 A factory that builds cls(...) therefore works for subclasses with no change. A static method that names the base class does not:

class Duration:
    def __init__(self, seconds):
        self.seconds = seconds

    @classmethod
    def of_minutes(cls, minutes):
        return cls(minutes * 60)

    @staticmethod
    def of_hours(hours):
        return Duration(hours * 3600)


class LabeledDuration(Duration):
    def __str__(self):
        return f"{self.seconds} seconds"


print(type(LabeledDuration.of_minutes(2)).__name__)
print(type(LabeledDuration.of_hours(1)).__name__)
Output
LabeledDuration
Duration

The Python standard library uses class methods for its alternative constructors, such as datetime.date.fromtimestamp.11

Factory functions. In a language with functions outside classes, the factory is a plain function of the module. Go has no constructors, and Effective Go shows NewFile as a function that builds and returns a *File.5 Kotlin puts factory functions in a companion object, such as Point.fromPolar, or at the top level.10

Collection factories. Java's List.of and List.copyOf are static factory methods that create unmodifiable lists.12 The declared return type is the interface List, so the caller does not depend on the class that implements it.

Named constructor idiom. The C++ FAQ gives the same design this name. All constructors are private or protected, and public static methods return the object, one method for each way to construct it.13 .NET has static factory methods next to public constructors, such as TimeSpan.FromSeconds.14

Simple factory. A Simple factory is a function that takes a parameter, such as a type name, and returns one of several classes. It is a static factory method whose main job is advantage 4, the choice of the class.

Singleton and Multiton. A static method that always returns the same instance is the access point of a Singleton pattern. One that returns one instance for each key is a Multiton. Both are static factory methods with a cache.

Flyweight. A factory method that returns shared instances of small immutable objects is the factory of the Flyweight pattern. Integer.valueOf is an example.

Known uses

References

  1. Joshua Bloch, Effective Java, third edition, Addison-Wesley, 2018, Item 1, Consider static factory methods instead of constructors (advantages, disadvantages, common names)
  2. Array.of(), MDN Web Docs, Description
  3. Joshua Bloch, Effective Java Programming Language Guide, Addison-Wesley, 2001, Chapter 2, Item 1
  4. Rust API Guidelines, Predictability, C-CTOR, Constructors are static, inherent methods
  5. Effective Go, Constructors and composite literals; Package names (ring.New)
  6. The Python Standard Library, Built-in Functions, Python 3.14, classmethod
  7. Java SE 25 API, java.lang.Integer, valueOf(int); Constructor Summary (Integer(int) is deprecated)
  8. OpenJDK jdk-25+36 source, java/util/EnumSet.java, noneOf, lines 112 to 122
  9. Gamma, Helm, Johnson and Vlissides, Design Patterns, Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994, Chapter 3, Factory Method (Intent, Structure)
  10. Kotlin coding conventions, Factory functions
  11. The Python Standard Library, datetime, Python 3.14, date.fromtimestamp
  12. Java SE 25 API, java.util.List, Unmodifiable Lists
  13. C++ FAQ, Constructors, Standard C++ Foundation, What is the Named Constructor Idiom?
  14. TimeSpan.FromSeconds Method, .NET API reference, Overloads
  15. OpenJDK jdk-25+36 source, java/time/Duration.java, ofSeconds, lines 225 to 227; create, lines 518 to 523

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/1ESRA6/text.yaml