Patterncore
Abstract Factory pattern
Also called Abstract Factory, Kit, factory object.
One object has a factory method for each kind of product in a family. Client code gets all of its products from that object, so it never names a concrete class and never mixes two families.
- Family
- creational-design
- Intent
- Give an interface for creating families of related objects, so that client code creates them without naming their concrete classes, and so that one choice selects the whole family.
- Also called
- Kit
Intent
Give an interface for creating families of related or dependent objects without naming their concrete classes.1 The client asks one object for each product it needs. The program chooses that object once, and the choice fixes the family of every product the client gets.
Problem
A program draws a form with a button and a checkbox. It supports two visual styles. In the plain style, a button is [ Save ] and a checked box is [x]. In the round style, they are ( Save ) and (*). A form must not mix the styles.
The first version tests the style where it creates each widget. That test is repeated at each place that creates a widget. When the program gains the round style, one place is missed, and the form mixes the families:
This code runs but gives a wrong answer on purpose.
def plain_button(label):
return f"[ {label} ]"
def plain_checkbox(label, checked):
return f"[{'x' if checked else ' '}] {label}"
def round_button(label):
return f"( {label} )"
def round_checkbox(label, checked):
return f"({'*' if checked else ' '}) {label}"
def login_form(style):
button = round_button("Save") if style == "round" else plain_button("Save")
checkbox = plain_checkbox("Remember me", True) # this line was not updated for "round"
return f"{button} {checkbox}"
print(login_form("round"))
( Save ) [x] Remember me
Design Patterns uses the same problem: a user interface toolkit that supports several look-and-feel standards, such as Motif and Presentation Manager.1 The forces are these. The client must not depend on concrete product classes. The products of one family must be used together. And the program should change families in one place.
Solution
Design Patterns names five participants.1
- AbstractFactory declares one creation operation for each kind of product.
- ConcreteFactory implements the operations for one family.
- AbstractProduct declares the interface of one kind of product.
- ConcreteProduct is a product of one family, made by the matching concrete factory.
- Client uses only the abstract factory and the abstract products.
The program makes one concrete factory, often at startup, and passes it to the client. The client calls button and checkbox on it and never names PlainButton or RoundCheckbox. All products come from one object, so they come from one family. Each creation operation is usually a factory method, so an abstract factory is a set of factory methods on one object.1 The Factory Method pattern page covers that part.
The choice of the family moves to one line, the line that makes the concrete factory. The rest of the program depends on interfaces only.
Example
The example files draw the same login form with both families. The output is plain: [ Save ] [x] Remember me, then round: ( Save ) (*) Remember me. The function login_form is the client and is the same for both families:
| Language | Form |
|---|---|
| Python | abstract base classes with abc.abstractmethod8 |
| JavaScript | a frozen object literal of factory functions for each family |
| TypeScript | an interface that each factory class implements |
| Java | interfaces for the factory and the products, and records for the products |
| C# | interfaces and records |
| C++ | abstract classes, with std::unique_ptr for the products |
| Go | an interface, with unexported product types |
| Rust | a trait with associated types for the products, and a generic client |
In the Rust file, the trait names the product types of each family. A generic client login_form<F: WidgetFactory> gets F::Button and F::Checkbox, so the compiler knows that both come from the same family.
from abc import ABC, abstractmethod
class Button(ABC):
@abstractmethod
def render(self) -> str: ...
class Checkbox(ABC):
@abstractmethod
def render(self) -> str: ...
class WidgetFactory(ABC):
@abstractmethod
def button(self, label: str) -> Button: ...
@abstractmethod
def checkbox(self, label: str, checked: bool) -> Checkbox: ...
class PlainButton(Button):
def __init__(self, label: str) -> None:
self.label = label
def render(self) -> str:
return f"[ {self.label} ]"
class PlainCheckbox(Checkbox):
def __init__(self, label: str, checked: bool) -> None:
self.label, self.checked = label, checked
def render(self) -> str:
return f"[{'x' if self.checked else ' '}] {self.label}"
class RoundButton(Button):
def __init__(self, label: str) -> None:
self.label = label
def render(self) -> str:
return f"( {self.label} )"
class RoundCheckbox(Checkbox):
def __init__(self, label: str, checked: bool) -> None:
self.label, self.checked = label, checked
def render(self) -> str:
return f"({'*' if self.checked else ' '}) {self.label}"
class PlainFactory(WidgetFactory):
def button(self, label):
return PlainButton(label)
def checkbox(self, label, checked):
return PlainCheckbox(label, checked)
class RoundFactory(WidgetFactory):
def button(self, label):
return RoundButton(label)
def checkbox(self, label, checked):
return RoundCheckbox(label, checked)
def login_form(widgets: WidgetFactory) -> str:
"""The client. It names no concrete widget class."""
return " ".join([widgets.button("Save").render(), widgets.checkbox("Remember me", True).render()])
for name, factory in [("plain", PlainFactory()), ("round", RoundFactory())]:
print(f"{name}: {login_form(factory)}")
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. Abstract base classes give the classic form.
abc.abstractmethodstops a concrete factory from being created until it has every factory method. - A class is a callable object in Python, so a concrete factory can be any object whose attributes are classes, such as a module or a
types.SimpleNamespace(button=PlainButton, checkbox=PlainCheckbox). The node shows this variant. - The DB-API of PEP 249 has the same shape at the level of modules. Each driver module has a
connectconstructor, and the connection makes cursors of the same driver.
#include <iostream>
#include <memory>
#include <string>
struct Widget {
virtual ~Widget() = default;
virtual std::string render() const = 0;
};
struct WidgetFactory {
virtual ~WidgetFactory() = default;
virtual std::unique_ptr<Widget> button(const std::string& label) const = 0;
virtual std::unique_ptr<Widget> checkbox(const std::string& label, bool checked) const = 0;
};
struct PlainButton : Widget {
std::string label;
explicit PlainButton(std::string l) : label(std::move(l)) {}
std::string render() const override { return "[ " + label + " ]"; }
};
struct PlainCheckbox : Widget {
std::string label;
bool checked;
PlainCheckbox(std::string l, bool c) : label(std::move(l)), checked(c) {}
std::string render() const override { return std::string("[") + (checked ? "x" : " ") + "] " + label; }
};
struct RoundButton : Widget {
std::string label;
explicit RoundButton(std::string l) : label(std::move(l)) {}
std::string render() const override { return "( " + label + " )"; }
};
struct RoundCheckbox : Widget {
std::string label;
bool checked;
RoundCheckbox(std::string l, bool c) : label(std::move(l)), checked(c) {}
std::string render() const override { return std::string("(") + (checked ? "*" : " ") + ") " + label; }
};
struct PlainFactory : WidgetFactory {
std::unique_ptr<Widget> button(const std::string& label) const override {
return std::make_unique<PlainButton>(label);
}
std::unique_ptr<Widget> checkbox(const std::string& label, bool checked) const override {
return std::make_unique<PlainCheckbox>(label, checked);
}
};
struct RoundFactory : WidgetFactory {
std::unique_ptr<Widget> button(const std::string& label) const override {
return std::make_unique<RoundButton>(label);
}
std::unique_ptr<Widget> checkbox(const std::string& label, bool checked) const override {
return std::make_unique<RoundCheckbox>(label, checked);
}
};
std::string login_form(const WidgetFactory& widgets) {
return widgets.button("Save")->render() + " " + widgets.checkbox("Remember me", true)->render();
}
int main() {
std::cout << "plain: " << login_form(PlainFactory{}) << "\n";
std::cout << "round: " << login_form(RoundFactory{}) << "\n";
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. Abstract classes with pure virtual functions. Each factory method returns
std::unique_ptr<Widget>, so the caller owns the product and the virtual destructor frees it. - A template parameter can take the place of the abstract factory, as the trait does in Rust.
template <class Factory> std::string login_form(const Factory&)binds the family at compile time and needs no virtual calls. - The client takes the factory by reference to
const. The factories have no state, so one instance of each is enough.
import java.util.LinkedHashMap;
import java.util.Map;
public class Main {
interface Widget {
String render();
}
interface WidgetFactory {
Widget button(String label);
Widget checkbox(String label, boolean checked);
}
record PlainButton(String label) implements Widget {
public String render() {
return "[ " + label + " ]";
}
}
record PlainCheckbox(String label, boolean checked) implements Widget {
public String render() {
return "[" + (checked ? "x" : " ") + "] " + label;
}
}
record RoundButton(String label) implements Widget {
public String render() {
return "( " + label + " )";
}
}
record RoundCheckbox(String label, boolean checked) implements Widget {
public String render() {
return "(" + (checked ? "*" : " ") + ") " + label;
}
}
static final class PlainFactory implements WidgetFactory {
public Widget button(String label) {
return new PlainButton(label);
}
public Widget checkbox(String label, boolean checked) {
return new PlainCheckbox(label, checked);
}
}
static final class RoundFactory implements WidgetFactory {
public Widget button(String label) {
return new RoundButton(label);
}
public Widget checkbox(String label, boolean checked) {
return new RoundCheckbox(label, checked);
}
}
static String loginForm(WidgetFactory widgets) {
return widgets.button("Save").render() + " " + widgets.checkbox("Remember me", true).render();
}
public static void main(String[] args) {
Map<String, WidgetFactory> kits = new LinkedHashMap<>();
kits.put("plain", new PlainFactory());
kits.put("round", new RoundFactory());
kits.forEach((name, kit) -> System.out.println(name + ": " + loginForm(kit)));
}
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. The classic form: an interface for the factory, an interface for the products, and a class for each concrete product and each concrete factory.
- The client
loginFormdepends only onWidgetFactoryandWidget. The program chooses the family once, when it puts a factory in the map. - A
defaultmethod in the factory interface can give a fallback for a product that is added later, so the existing factories still compile. The .NET classDbProviderFactorydoes the same with virtual methods (see the node).
var kits = new (string Name, IWidgetFactory Kit)[] { ("plain", new PlainFactory()), ("round", new RoundFactory()) };
foreach (var (name, kit) in kits)
{
Console.WriteLine($"{name}: {LoginForm(kit)}");
}
static string LoginForm(IWidgetFactory widgets) =>
$"{widgets.Button("Save").Render()} {widgets.Checkbox("Remember me", true).Render()}";
interface IWidget
{
string Render();
}
interface IWidgetFactory
{
IWidget Button(string label);
IWidget Checkbox(string label, bool @checked);
}
record PlainButton(string Label) : IWidget
{
public string Render() => $"[ {Label} ]";
}
record PlainCheckbox(string Label, bool Checked) : IWidget
{
public string Render() => $"[{(Checked ? "x" : " ")}] {Label}";
}
record RoundButton(string Label) : IWidget
{
public string Render() => $"( {Label} )";
}
record RoundCheckbox(string Label, bool Checked) : IWidget
{
public string Render() => $"({(Checked ? "*" : " ")}) {Label}";
}
sealed class PlainFactory : IWidgetFactory
{
public IWidget Button(string label) => new PlainButton(label);
public IWidget Checkbox(string label, bool @checked) => new PlainCheckbox(label, @checked);
}
sealed class RoundFactory : IWidgetFactory
{
public IWidget Button(string label) => new RoundButton(label);
public IWidget Checkbox(string label, bool @checked) => new RoundCheckbox(label, @checked);
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. The classic form with interfaces and records.
System.Data.Common.DbProviderFactoryin .NET is an abstract factory for the classes of one database provider: connections, commands, parameters and others. Its factory methods are virtual with a default, so a provider that does not support a product still compiles (see the node).- A dependency injection container often holds the factory. The program registers one concrete factory at startup, and each class that needs widgets takes an
IWidgetFactoryin its constructor.
const plain = Object.freeze({
button: (label) => ({ render: () => `[ ${label} ]` }),
checkbox: (label, checked) => ({ render: () => `[${checked ? "x" : " "}] ${label}` }),
});
const round = Object.freeze({
button: (label) => ({ render: () => `( ${label} )` }),
checkbox: (label, checked) => ({ render: () => `(${checked ? "*" : " "}) ${label}` }),
});
// The client. It knows only the two factory functions of a kit.
function loginForm(widgets) {
return [widgets.button("Save").render(), widgets.checkbox("Remember me", true).render()].join(" ");
}
for (const [name, kit] of Object.entries({ plain, round })) {
console.log(`${name}: ${loginForm(kit)}`);
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. A concrete factory is an object literal whose properties are functions, and each product is an object with a
rendermethod. No class or interface is needed. - Nothing checks that a kit has every factory function. A kit that lacks
checkboxfails only when the client calls it, with aTypeError. TypeScript moves this check to compile time. Object.freezestops code from replacing one function of a kit, which would mix families.
interface Widget {
render(): string;
}
interface WidgetFactory {
button(label: string): Widget;
checkbox(label: string, checked: boolean): Widget;
}
class PlainFactory implements WidgetFactory {
button(label: string): Widget {
return { render: () => `[ ${label} ]` };
}
checkbox(label: string, checked: boolean): Widget {
return { render: () => `[${checked ? "x" : " "}] ${label}` };
}
}
class RoundFactory implements WidgetFactory {
button(label: string): Widget {
return { render: () => `( ${label} )` };
}
checkbox(label: string, checked: boolean): Widget {
return { render: () => `(${checked ? "*" : " "}) ${label}` };
}
}
function loginForm(widgets: WidgetFactory): string {
return [widgets.button("Save").render(), widgets.checkbox("Remember me", true).render()].join(" ");
}
const kits: [string, WidgetFactory][] = [
["plain", new PlainFactory()],
["round", new RoundFactory()],
];
for (const [name, kit] of kits) {
console.log(`${name}: ${loginForm(kit)}`);
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. An interface declares the factory methods, and
implementsmakes the compiler check that each concrete factory has all of them. - The type system of TypeScript is structural. An object literal with the two methods is a
WidgetFactorywith noimplementsclause, so the JavaScript form also type-checks. - When a method is added to
WidgetFactory, each class that implements it is a compile error until it gets the method. This is the liability of a new kind of product, found by the compiler.
package main
import "fmt"
type Widget interface{ Render() string }
type WidgetFactory interface {
Button(label string) Widget
Checkbox(label string, checked bool) Widget
}
type plainButton struct{ label string }
type plainCheckbox struct {
label string
checked bool
}
type roundButton struct{ label string }
type roundCheckbox struct {
label string
checked bool
}
func (b plainButton) Render() string { return "[ " + b.label + " ]" }
func (c plainCheckbox) Render() string {
mark := " "
if c.checked {
mark = "x"
}
return "[" + mark + "] " + c.label
}
func (b roundButton) Render() string { return "( " + b.label + " )" }
func (c roundCheckbox) Render() string {
mark := " "
if c.checked {
mark = "*"
}
return "(" + mark + ") " + c.label
}
type Plain struct{}
type Round struct{}
func (Plain) Button(label string) Widget { return plainButton{label} }
func (Plain) Checkbox(label string, checked bool) Widget { return plainCheckbox{label, checked} }
func (Round) Button(label string) Widget { return roundButton{label} }
func (Round) Checkbox(label string, checked bool) Widget { return roundCheckbox{label, checked} }
func loginForm(widgets WidgetFactory) string {
return widgets.Button("Save").Render() + " " + widgets.Checkbox("Remember me", true).Render()
}
func main() {
kits := []struct {
name string
kit WidgetFactory
}{{"plain", Plain{}}, {"round", Round{}}}
for _, k := range kits {
fmt.Printf("%s: %s\n", k.name, loginForm(k.kit))
}
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. A Go interface lists the factory methods, and a type satisfies it by having them. The concrete factories are empty structs, so they cost nothing to pass.
- The product types are not exported. A caller outside the package can get a widget only from a factory, so it cannot mix families by calling a constructor.
- The
database/sql/driverpackage has this shape. ADriveropens aConn, and the connection prepares statements and begins transactions of the same driver.
trait Widget {
fn render(&self) -> String;
}
trait WidgetFactory {
type Button: Widget;
type Checkbox: Widget;
fn button(&self, label: &str) -> Self::Button;
fn checkbox(&self, label: &str, checked: bool) -> Self::Checkbox;
}
struct PlainButton(String);
struct PlainCheckbox(String, bool);
struct RoundButton(String);
struct RoundCheckbox(String, bool);
impl Widget for PlainButton {
fn render(&self) -> String {
format!("[ {} ]", self.0)
}
}
impl Widget for PlainCheckbox {
fn render(&self) -> String {
format!("[{}] {}", if self.1 { "x" } else { " " }, self.0)
}
}
impl Widget for RoundButton {
fn render(&self) -> String {
format!("( {} )", self.0)
}
}
impl Widget for RoundCheckbox {
fn render(&self) -> String {
format!("({}) {}", if self.1 { "*" } else { " " }, self.0)
}
}
struct Plain;
struct Round;
impl WidgetFactory for Plain {
type Button = PlainButton;
type Checkbox = PlainCheckbox;
fn button(&self, label: &str) -> PlainButton {
PlainButton(label.into())
}
fn checkbox(&self, label: &str, checked: bool) -> PlainCheckbox {
PlainCheckbox(label.into(), checked)
}
}
impl WidgetFactory for Round {
type Button = RoundButton;
type Checkbox = RoundCheckbox;
fn button(&self, label: &str) -> RoundButton {
RoundButton(label.into())
}
fn checkbox(&self, label: &str, checked: bool) -> RoundCheckbox {
RoundCheckbox(label.into(), checked)
}
}
// Generic over one factory type F: every widget comes from the same family.
fn login_form<F: WidgetFactory>(widgets: &F) -> String {
format!("{} {}", widgets.button("Save").render(), widgets.checkbox("Remember me", true).render())
}
fn main() {
println!("plain: {}", login_form(&Plain));
println!("round: {}", login_form(&Round));
}
plain: [ Save ] [x] Remember me
round: ( Save ) (*) Remember me
- Verdict: idiom. A trait with associated types names the product types of each family. Each
implfixes them once, soF::ButtonandF::Checkboxalways belong to the sameF. login_formis generic, so the compiler makes one copy for each factory and the calls are static. A&dynfactory would need the products boxed asBox<dyn Widget>, with the family chosen at run time.- The concrete factories are unit structs with no data. The factory is a type more than a value, which is close to Norvig's point about first-class types (see the node).
Consequences
Design Patterns lists four consequences.1 The pattern isolates concrete classes, because the client handles products only through their interfaces. It makes a change of product family a small change, because the concrete factory appears once in the program. It promotes consistency among products, because a client that uses one factory gets one family. These are the benefits.
The fourth consequence is the liability. Support for a new kind of product is hard to add. The abstract factory fixes the set of products it can create. A new kind, such as a slider, changes the abstract factory and every concrete factory.1 In Python, an abstract base class makes this visible. A concrete factory that lacks the new method cannot be created:8
This code raises TypeError, on purpose.
from abc import ABC, abstractmethod
class WidgetFactory(ABC):
@abstractmethod
def button(self, label): ...
@abstractmethod
def checkbox(self, label, checked): ...
@abstractmethod
def slider(self, label, value): ... # the new kind of product
class PlainFactory(WidgetFactory):
def button(self, label):
return f"[ {label} ]"
def checkbox(self, label, checked):
return f"[{'x' if checked else ' '}] {label}"
PlainFactory()
In Java, C#, TypeScript, Go and Rust, the same change is a compile error for each concrete factory. The error is the useful part: it lists each family that needs the new product. The cost grows with the number of families times the number of products.
A library with factories that it does not own cannot make that change. The .NET class DbProviderFactory shows one way out. It is an abstract class, and its creation methods are virtual with a default. CreateConnection, CreateCommand and CreateParameter return null when a provider does not override them. CreateBatch throws NotSupportedException, and the property CanCreateBatch is false by default.7 A provider written before batches existed still compiles, and a client asks CanCreateBatch before it calls CreateBatch. The price is a check at run time in place of a compile error. A Java interface can do the same with default methods.
The pattern also adds types. Two families of two products need an abstract factory, two concrete factories, two product interfaces and four product classes. The pattern pays off when the client is large and the families are real. It does not pay off for one family with a second one that may come later.
One factory for the whole program. A concrete factory usually has no state, and a program usually needs one for each family. Design Patterns notes that a concrete factory is often a singleton.1 Make one instance at startup and pass it in. The Singleton pattern page explains why a global instance is often worse than a parameter.
When not to use it
Do not use the pattern for one family. A direct constructor call is clearer, and adding the factory later is a local change if the client code takes its products from few places.
Do not use it when the products of different families can be mixed safely. The pattern exists to keep a family together. If any button can go with any checkbox, pass each factory function or class on its own.
Do not use it when the set of products changes often and the set of families is stable. Each new product changes every factory. When the products vary more than the families, group the code by product. The trade-off is the expression problem, which the Composite pattern page describes.
Do not write a class hierarchy of factories in a language where a class or a module is a value. A record of classes or a module does the same work.
Variants and related patterns
Classes or modules as factories. Norvig points out that in a language with first-class types, a class is already a factory. The program can store classes in variables and needs no parallel hierarchy of factory classes. He also notes that a programmer may still want a factory-like object that bundles the classes of one family.2 In Python, that object can be a namespace of classes:
from types import SimpleNamespace
class PlainButton:
def __init__(self, label):
self.label = label
def render(self):
return f"[ {self.label} ]"
class RoundButton(PlainButton):
def render(self):
return f"( {self.label} )"
kits = {
"plain": SimpleNamespace(button=PlainButton),
"round": SimpleNamespace(button=RoundButton),
}
widgets = kits["round"] # the one place that chooses the family
print(widgets.button("Save").render())
( Save )
A Python module can be the kit too. PEP 249 has this shape. Each database module has a connect constructor that returns a connection, and the connection's cursor method returns a cursor of the same driver.34 The program imports one module, and every object it gets from the module belongs to that driver. Go's database/sql/driver package is the same idea with interfaces. A Driver opens a Conn, and the connection prepares statements of its own driver.5
Dependency injection. A dependency injection container is a general factory. The program registers the concrete classes in one place, and the container passes them to the classes that need them. In his 2009 draft of a revised catalog, Gamma proposed to add Dependency Injection as a pattern.10 With a container, the abstract factory often becomes one registration of the family's classes.
Factory Method. An abstract factory is often a set of factory methods. The difference is the place of the choice. In Factory Method, a subclass of the client chooses the product. In Abstract Factory, the client receives an object that chooses.1 See Factory Method pattern.
Builder. Design Patterns contrasts the two. Abstract Factory makes a family of products, and each product returns at once. Builder makes one complex product step by step and returns it as a final step.9 See Builder pattern.
Prototype. A concrete factory can hold one prototype instance of each product and copy it, in place of a subclass for each family. Design Patterns describes this in its Implementation section.1
Strategy. An abstract factory is a strategy for creation. A client that receives a factory has one of its decisions made by another object, as a client of a strategy does. The Strategy pattern page covers the general case.
Known uses
- .NET: DbProviderFactory at v10.0.0 is an abstract class with creation methods for the connection, command, parameter, command builder, data adapter and batch classes of one data provider. Each provider derives a concrete factory. The methods are virtual with a default, which keeps old providers working when a product is added.67
- Python: the DB-API of PEP 249. Each driver module is a kit whose
connectreturns a connection, and whose connection returns cursors of the same driver.34 - Go: the
database/sql/driverinterfaces. A driver opens connections, and a connection prepares statements and begins transactions of the same driver.5
References
- Gamma, Helm, Johnson and Vlissides, Design Patterns, Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994, Chapter 3, Abstract Factory (Intent, Also Known As, Motivation, Participants, Consequences, Implementation, Related Patterns)
- Peter Norvig, Design Patterns in Dynamic Programming, Object World, May 1996, slide 10 (first-class types make Abstract-Factory simpler) and slides 12 and 13 (Abstract Factory in a dynamic language)
- PEP 249, Python Database API Specification v2.0, Module Interface, Constructors (connect returns a Connection object)
- PEP 249, Python Database API Specification v2.0, Connection Objects, Connection methods (.cursor)
- Go standard library, database/sql/driver, type Driver; type Conn
- .NET API reference, System.Data.Common.DbProviderFactory, class description and methods
- dotnet/runtime v10.0.0 source, System.Data.Common/DbProviderFactory.cs, class DbProviderFactory, lines 9 to 72
- The Python Standard Library, abc, Python 3.14, abc.abstractmethod
- Gamma, Helm, Johnson and Vlissides, Design Patterns, Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994, Chapter 3, Builder (Related Patterns)
- Larry O'Brien, Design Patterns 15 Years Later, An Interview with Erich Gamma, Richard Helm, and Ralph Johnson, InformIT, October 22, 2009, Gamma's draft of a revised catalog (generalize Factory Method to Factory; add Dependency Injection)
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag EYCWG5 Edit this page History Report an error Markdown