{
  "code": null,
  "collection": "architecture",
  "href": "https://banes-lab.com/ontology#architecture-registry-pattern",
  "id": "registry-pattern",
  "kind": "pattern",
  "layer": {
    "href": "https://banes-lab.com/ontology/schema#layer-extensibility-core",
    "json": "https://banes-lab.com/json/records/layer/extensibility-core",
    "label": "Extensibility Core",
    "markdown": "https://banes-lab.com/records/layer/extensibility-core.md",
    "ref": "layer:extensibility-core"
  },
  "name": "Registry Pattern",
  "ref": "architecture:registry-pattern",
  "relations": [
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-keyed-registration",
          "json": "https://banes-lab.com/json/records/lexicon/keyed-registration",
          "label": "Keyed Registration",
          "markdown": "https://banes-lab.com/records/lexicon/keyed-registration.md",
          "ref": "lexicon:keyed-registration"
        }
      ],
      "relation": "requires"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-discovery",
          "json": "https://banes-lab.com/json/records/lexicon/discovery",
          "label": "Discovery",
          "markdown": "https://banes-lab.com/records/lexicon/discovery.md",
          "ref": "lexicon:discovery"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-factory-pattern",
          "json": "https://banes-lab.com/json/records/architecture/factory-pattern",
          "label": "Factory Pattern",
          "markdown": "https://banes-lab.com/records/architecture/factory-pattern.md",
          "ref": "architecture:factory-pattern"
        }
      ],
      "relation": "reinforces"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-dynamic-lookup",
          "json": "https://banes-lab.com/json/records/lexicon/dynamic-lookup",
          "label": "Dynamic Lookup",
          "markdown": "https://banes-lab.com/records/lexicon/dynamic-lookup.md",
          "ref": "lexicon:dynamic-lookup"
        }
      ],
      "relation": "enables"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-direct-reference",
          "json": "https://banes-lab.com/json/records/lexicon/direct-reference",
          "label": "Direct Reference",
          "markdown": "https://banes-lab.com/records/lexicon/direct-reference.md",
          "ref": "lexicon:direct-reference"
        }
      ],
      "relation": "conflicts-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-global-state",
          "json": "https://banes-lab.com/json/records/lexicon/global-state",
          "label": "Global State",
          "markdown": "https://banes-lab.com/records/lexicon/global-state.md",
          "ref": "lexicon:global-state"
        }
      ],
      "relation": "tensions-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/schema#tension-global-state-registry-pattern",
          "json": "https://banes-lab.com/json/records/tension/global-state-registry-pattern",
          "label": "Registry Pattern / Global State",
          "markdown": "https://banes-lab.com/records/tension/global-state-registry-pattern.md",
          "ref": "tension:global-state-registry-pattern"
        }
      ],
      "relation": "tensions"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-ungoverned-global-registry",
          "json": "https://banes-lab.com/json/records/lexicon/ungoverned-global-registry",
          "label": "Ungoverned Global Registry",
          "markdown": "https://banes-lab.com/records/lexicon/ungoverned-global-registry.md",
          "ref": "lexicon:ungoverned-global-registry"
        }
      ],
      "relation": "violated-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-narrow-type",
          "json": "https://banes-lab.com/json/records/lexicon/narrow-type",
          "label": "Narrow Type",
          "markdown": "https://banes-lab.com/records/lexicon/narrow-type.md",
          "ref": "lexicon:narrow-type"
        }
      ],
      "relation": "refactored-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/schema#vocabulary-severity-contextual",
          "json": "https://banes-lab.com/json/records/vocabulary/severity-contextual",
          "label": "contextual",
          "markdown": "https://banes-lab.com/records/vocabulary/severity-contextual.md",
          "ref": "vocabulary:severity-contextual"
        }
      ],
      "relation": "severity"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-category-plugin-extensibility-ioc",
          "json": "https://banes-lab.com/json/records/architecture-category/plugin-extensibility-ioc",
          "label": "Plugin / Extensibility / IoC",
          "markdown": "https://banes-lab.com/records/architecture-category/plugin-extensibility-ioc.md",
          "ref": "architecture-category:plugin-extensibility-ioc"
        }
      ],
      "relation": "category"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/anatomy/governance#file-governance-rules-eslint-closure-register-needs-consumer-eslint-rule-ts",
          "json": "https://banes-lab.com/json/source/governance/rules/eslint/closure-register-needs-consumer.eslint.rule.ts",
          "label": "rules/eslint/closure-register-needs-consumer.eslint.rule.ts",
          "markdown": "https://banes-lab.com/source/governance/rules/eslint/closure-register-needs-consumer.eslint.rule.ts.md",
          "ref": "anatomy:file-governance-rules-eslint-closure-register-needs-consumer-eslint-rule-ts"
        },
        {
          "href": "https://banes-lab.com/anatomy/governance#file-governance-rules-eslint-closure-registry-consumer-naming-eslint-rule-ts",
          "json": "https://banes-lab.com/json/source/governance/rules/eslint/closure-registry-consumer-naming.eslint.rule.ts",
          "label": "rules/eslint/closure-registry-consumer-naming.eslint.rule.ts",
          "markdown": "https://banes-lab.com/source/governance/rules/eslint/closure-registry-consumer-naming.eslint.rule.ts.md",
          "ref": "anatomy:file-governance-rules-eslint-closure-registry-consumer-naming-eslint-rule-ts"
        },
        {
          "href": "https://banes-lab.com/anatomy/governance#file-governance-rules-eslint-require-pool-registration-eslint-rule-ts",
          "json": "https://banes-lab.com/json/source/governance/rules/eslint/require-pool-registration.eslint.rule.ts",
          "label": "rules/eslint/require-pool-registration.eslint.rule.ts",
          "markdown": "https://banes-lab.com/source/governance/rules/eslint/require-pool-registration.eslint.rule.ts.md",
          "ref": "anatomy:file-governance-rules-eslint-require-pool-registration-eslint-rule-ts"
        },
        {
          "href": "https://banes-lab.com/anatomy/governance#file-governance-rules-eslint-require-self-registration-eslint-rule-ts",
          "json": "https://banes-lab.com/json/source/governance/rules/eslint/require-self-registration.eslint.rule.ts",
          "label": "rules/eslint/require-self-registration.eslint.rule.ts",
          "markdown": "https://banes-lab.com/source/governance/rules/eslint/require-self-registration.eslint.rule.ts.md",
          "ref": "anatomy:file-governance-rules-eslint-require-self-registration-eslint-rule-ts"
        }
      ],
      "relation": "enforced-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-runtime-discovery",
          "json": "https://banes-lab.com/json/records/architecture/runtime-discovery",
          "label": "Runtime Discovery",
          "markdown": "https://banes-lab.com/records/architecture/runtime-discovery.md",
          "ref": "architecture:runtime-discovery"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-event-bus",
          "json": "https://banes-lab.com/json/records/architecture/event-bus",
          "label": "Event Bus",
          "markdown": "https://banes-lab.com/records/architecture/event-bus.md",
          "ref": "architecture:event-bus"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-model-governance",
          "json": "https://banes-lab.com/json/records/architecture/model-governance",
          "label": "Model Governance",
          "markdown": "https://banes-lab.com/records/architecture/model-governance.md",
          "ref": "architecture:model-governance"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-plugin-architecture",
          "json": "https://banes-lab.com/json/records/architecture/plugin-architecture",
          "label": "Plugin Architecture",
          "markdown": "https://banes-lab.com/records/architecture/plugin-architecture.md",
          "ref": "architecture:plugin-architecture"
        }
      ],
      "relation": "refactors"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/disciplined-methodology/plan#when-rules-collide",
          "json": "https://banes-lab.com/json/disciplined-methodology/plan/when-rules-collide",
          "label": "When rules collide",
          "markdown": "https://banes-lab.com/disciplined-methodology/plan/when-rules-collide.md",
          "ref": "chapter:/disciplined-methodology/plan#when-rules-collide"
        },
        {
          "href": "https://banes-lab.com/disciplined-methodology/build#a-check-matches-a-shape",
          "json": "https://banes-lab.com/json/disciplined-methodology/build/a-check-matches-a-shape",
          "label": "A check matches a shape",
          "markdown": "https://banes-lab.com/disciplined-methodology/build/a-check-matches-a-shape.md",
          "ref": "chapter:/disciplined-methodology/build#a-check-matches-a-shape"
        },
        {
          "href": "https://banes-lab.com/disciplined-methodology/build#the-filesystem-is-the-architecture",
          "json": "https://banes-lab.com/json/disciplined-methodology/build/the-filesystem-is-the-architecture",
          "label": "The filesystem is the architecture",
          "markdown": "https://banes-lab.com/disciplined-methodology/build/the-filesystem-is-the-architecture.md",
          "ref": "chapter:/disciplined-methodology/build#the-filesystem-is-the-architecture"
        },
        {
          "href": "https://banes-lab.com/software-architecture#definitions-own-what",
          "json": "https://banes-lab.com/json/software-architecture/model/definitions-own-what",
          "label": "Definitions own what, code owns how",
          "markdown": "https://banes-lab.com/software-architecture/model/definitions-own-what.md",
          "ref": "chapter:/software-architecture#definitions-own-what"
        },
        {
          "href": "https://banes-lab.com/software-architecture/coverage#the-honest-gaps",
          "json": "https://banes-lab.com/json/software-architecture/coverage/the-honest-gaps",
          "label": "The honest gaps",
          "markdown": "https://banes-lab.com/software-architecture/coverage/the-honest-gaps.md",
          "ref": "chapter:/software-architecture/coverage#the-honest-gaps"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-runtime-discovery-dynamic-binding",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-runtime-discovery-dynamic-binding",
          "label": "Runtime Discovery / Dynamic Binding",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-runtime-discovery-dynamic-binding.md",
          "ref": "chapter:/ontology#architecture-category-runtime-discovery-dynamic-binding"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-event-messaging-asynchronous-architecture",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-event-messaging-asynchronous-architecture",
          "label": "Event / Messaging / Asynchronous Architecture",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-event-messaging-asynchronous-architecture.md",
          "ref": "chapter:/ontology#architecture-category-event-messaging-asynchronous-architecture"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-model-architecture",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-model-architecture",
          "label": "Model Architecture",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-model-architecture.md",
          "ref": "chapter:/ontology#architecture-category-model-architecture"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-creational-patterns",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-creational-patterns",
          "label": "Creational Patterns",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-creational-patterns.md",
          "ref": "chapter:/ontology#architecture-category-creational-patterns"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-plugin-extensibility-ioc",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-plugin-extensibility-ioc",
          "label": "Plugin / Extensibility / IoC",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-plugin-extensibility-ioc.md",
          "ref": "chapter:/ontology#architecture-category-plugin-extensibility-ioc"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-core-vocabulary",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-core-vocabulary",
          "label": "Core Vocabulary",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-core-vocabulary.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-core-vocabulary"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-plugin-extensibility-ioc",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-plugin-extensibility-ioc",
          "label": "Plugin / Extensibility / IoC",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-plugin-extensibility-ioc.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-plugin-extensibility-ioc"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-schema-canonical-data-semantics",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-schema-canonical-data-semantics",
          "label": "Schema / Canonical Data / Semantics",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-schema-canonical-data-semantics.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-schema-canonical-data-semantics"
        },
        {
          "href": "https://banes-lab.com/ontology/schema#the-vocabulary-severity",
          "json": "https://banes-lab.com/json/ontology/schema/the-vocabulary-severity",
          "label": "Severity levels",
          "markdown": "https://banes-lab.com/ontology/schema/the-vocabulary-severity.md",
          "ref": "chapter:/ontology/schema#the-vocabulary-severity"
        },
        {
          "href": "https://banes-lab.com/ontology/schema#the-resolutions",
          "json": "https://banes-lab.com/json/ontology/schema/the-resolutions",
          "label": "The resolutions",
          "markdown": "https://banes-lab.com/ontology/schema/the-resolutions.md",
          "ref": "chapter:/ontology/schema#the-resolutions"
        }
      ],
      "relation": "linked-from"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/anatomy/tree#file-domain-registries-page-registry-ts",
          "json": "https://banes-lab.com/json/source/tree/domain/registries/page.registry.ts",
          "label": "registerPage",
          "markdown": "https://banes-lab.com/source/tree/domain/registries/page.registry.ts.md",
          "ref": "anatomy:file-domain-registries-page-registry-ts"
        },
        {
          "href": "https://banes-lab.com/anatomy/tree#folder-presentation-records",
          "json": "https://banes-lab.com/json/anatomy/tree/folder-presentation-records",
          "label": "presentation/records",
          "markdown": "https://banes-lab.com/anatomy/tree/folder-presentation-records.md",
          "ref": "chapter:/anatomy/tree#folder-presentation-records"
        },
        {
          "href": "https://banes-lab.com/anatomy/tree#file-presentation-records-records-barrel-ts",
          "json": "https://banes-lab.com/json/source/tree/presentation/records/records.barrel.ts",
          "label": "presentation/records/records.barrel.ts",
          "markdown": "https://banes-lab.com/source/tree/presentation/records/records.barrel.ts.md",
          "ref": "anatomy:file-presentation-records-records-barrel-ts"
        },
        {
          "href": "https://banes-lab.com/anatomy/tree#file-domain-registries-base-registry-ts",
          "json": "https://banes-lab.com/json/source/tree/domain/registries/base.registry.ts",
          "label": "createRegistry",
          "markdown": "https://banes-lab.com/source/tree/domain/registries/base.registry.ts.md",
          "ref": "anatomy:file-domain-registries-base-registry-ts"
        }
      ],
      "relation": "evidence"
    }
  ],
  "summary": "A design pattern that replaces a conditional over kinds with a keyed table that each kind registers itself into.",
  "siblings": {
    "next": {
      "href": "https://banes-lab.com/ontology#architecture-service-locator-pattern",
      "json": "https://banes-lab.com/json/records/architecture/service-locator-pattern",
      "label": "Service Locator Pattern",
      "markdown": "https://banes-lab.com/records/architecture/service-locator-pattern.md",
      "ref": "architecture:service-locator-pattern"
    },
    "previous": {
      "href": "https://banes-lab.com/ontology#architecture-service-registry",
      "json": "https://banes-lab.com/json/records/architecture/service-registry",
      "label": "Service Registry",
      "markdown": "https://banes-lab.com/records/architecture/service-registry.md",
      "ref": "architecture:service-registry"
    }
  },
  "up": {
    "href": null,
    "json": "https://banes-lab.com/json/api/records/architecture",
    "label": "Architecture principles",
    "markdown": "https://banes-lab.com/api/records/architecture.md",
    "ref": "api:records/architecture"
  },
  "aliases": [],
  "exemplar": {
    "after": "type FooFactory = () => Foo;\nconst registry = new Map<string, FooFactory>();\nexport const registerFoo = (kind: string, factory: FooFactory) => registry.set(kind, factory);\nexport const makeFoo = (kind: string) => registry.get(kind)?.() ?? fail(`unknown ${kind}`);",
    "before": "function makeFoo(kind: string) {\n  if (kind === \"foo\") return new Foo1();\n  if (kind === \"bar\") return new Bar();\n  throw new Error(\"unknown kind\");\n}",
    "lang": "ts",
    "medium": "code"
  },
  "formedBy": null,
  "scope": [
    "runtime",
    "module",
    "plugin"
  ],
  "severity": "contextual"
}
