{
  "code": null,
  "collection": "architecture",
  "href": "https://banes-lab.com/ontology#architecture-visitor-pattern",
  "id": "visitor-pattern",
  "kind": "pattern",
  "layer": {
    "href": "https://banes-lab.com/ontology/schema#layer-design-patterns-core",
    "json": "https://banes-lab.com/json/records/layer/design-patterns-core",
    "label": "Design Patterns Core",
    "markdown": "https://banes-lab.com/records/layer/design-patterns-core.md",
    "ref": "layer:design-patterns-core"
  },
  "name": "Visitor Pattern",
  "ref": "architecture:visitor-pattern",
  "relations": [
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-stable-element-hierarchy",
          "json": "https://banes-lab.com/json/records/lexicon/stable-element-hierarchy",
          "label": "Stable Element Hierarchy",
          "markdown": "https://banes-lab.com/records/lexicon/stable-element-hierarchy.md",
          "ref": "lexicon:stable-element-hierarchy"
        }
      ],
      "relation": "requires"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-open-closed",
          "json": "https://banes-lab.com/json/records/architecture/open-closed",
          "label": "Open/Closed Principle (OCP)",
          "markdown": "https://banes-lab.com/records/architecture/open-closed.md",
          "ref": "architecture:open-closed"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-separation-of-concerns",
          "json": "https://banes-lab.com/json/records/architecture/separation-of-concerns",
          "label": "Separation of Concerns",
          "markdown": "https://banes-lab.com/records/architecture/separation-of-concerns.md",
          "ref": "architecture:separation-of-concerns"
        }
      ],
      "relation": "reinforces"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-operation-extension-without-element-change",
          "json": "https://banes-lab.com/json/records/lexicon/operation-extension-without-element-change",
          "label": "Operation Extension Without Element Change",
          "markdown": "https://banes-lab.com/records/lexicon/operation-extension-without-element-change.md",
          "ref": "lexicon:operation-extension-without-element-change"
        }
      ],
      "relation": "enables"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-type-switching",
          "json": "https://banes-lab.com/json/records/lexicon/type-switching",
          "label": "Type Switching",
          "markdown": "https://banes-lab.com/records/lexicon/type-switching.md",
          "ref": "lexicon:type-switching"
        }
      ],
      "relation": "conflicts-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-element-stability",
          "json": "https://banes-lab.com/json/records/lexicon/element-stability",
          "label": "Element Stability",
          "markdown": "https://banes-lab.com/records/lexicon/element-stability.md",
          "ref": "lexicon:element-stability"
        }
      ],
      "relation": "tensions-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/schema#tension-element-stability-visitor-pattern",
          "json": "https://banes-lab.com/json/records/tension/element-stability-visitor-pattern",
          "label": "Visitor Pattern / Element Stability",
          "markdown": "https://banes-lab.com/records/tension/element-stability-visitor-pattern.md",
          "ref": "tension:element-stability-visitor-pattern"
        }
      ],
      "relation": "tensions"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-type-switching",
          "json": "https://banes-lab.com/json/records/lexicon/type-switching",
          "label": "Type Switching",
          "markdown": "https://banes-lab.com/records/lexicon/type-switching.md",
          "ref": "lexicon:type-switching"
        }
      ],
      "relation": "violated-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-behavioral-patterns",
          "json": "https://banes-lab.com/json/records/architecture-category/behavioral-patterns",
          "label": "Behavioral Patterns",
          "markdown": "https://banes-lab.com/records/architecture-category/behavioral-patterns.md",
          "ref": "architecture-category:behavioral-patterns"
        }
      ],
      "relation": "category"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-category-core-modular-design",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-core-modular-design",
          "label": "Core Modular Design",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-core-modular-design.md",
          "ref": "chapter:/ontology#architecture-category-core-modular-design"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-solid-object-oriented-design",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-solid-object-oriented-design",
          "label": "SOLID / Object-Oriented Design",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-solid-object-oriented-design.md",
          "ref": "chapter:/ontology#architecture-category-solid-object-oriented-design"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-behavioral-patterns",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-behavioral-patterns",
          "label": "Behavioral Patterns",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-behavioral-patterns.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-behavioral-patterns"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-solid-object-oriented-design",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-solid-object-oriented-design",
          "label": "SOLID / Object-Oriented Design",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-solid-object-oriented-design.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-solid-object-oriented-design"
        },
        {
          "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"
    }
  ],
  "summary": "A design pattern that places each operation over a type hierarchy in its own visitor, so an operation is added without editing the element types.",
  "siblings": {
    "next": {
      "href": "https://banes-lab.com/ontology#architecture-memento-pattern",
      "json": "https://banes-lab.com/json/records/architecture/memento-pattern",
      "label": "Memento Pattern",
      "markdown": "https://banes-lab.com/records/architecture/memento-pattern.md",
      "ref": "architecture:memento-pattern"
    },
    "previous": {
      "href": "https://banes-lab.com/ontology#architecture-iterator-pattern",
      "json": "https://banes-lab.com/json/records/architecture/iterator-pattern",
      "label": "Iterator Pattern",
      "markdown": "https://banes-lab.com/records/architecture/iterator-pattern.md",
      "ref": "architecture:iterator-pattern"
    }
  },
  "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": "interface FooVisitor<T> { text(node: TextNode): T; group(node: GroupNode): T; }\nclass RenderFooVisitor implements FooVisitor<string> {\n  text(node: TextNode) { return node.value; }\n  group(node: GroupNode) { return node.children.map(child => child.accept(this)).join(\"\"); }\n}",
    "before": "function renderFoo(node: FooNode) {\n  if (node.kind === \"text\") return node.value;\n  if (node.kind === \"group\") return node.children.map(renderFoo).join(\"\");\n}",
    "lang": "ts",
    "medium": "code"
  },
  "formedBy": null,
  "scope": [
    "behavior",
    "operation",
    "type hierarchy"
  ],
  "severity": "contextual"
}
