{
  "code": null,
  "collection": "architecture",
  "href": "https://banes-lab.com/ontology#architecture-design-by-contract",
  "id": "design-by-contract",
  "kind": "principle",
  "layer": {
    "href": "https://banes-lab.com/ontology/schema#layer-contracts-core",
    "json": "https://banes-lab.com/json/records/layer/contracts-core",
    "label": "Contracts Core",
    "markdown": "https://banes-lab.com/records/layer/contracts-core.md",
    "ref": "layer:contracts-core"
  },
  "name": "Design by Contract",
  "ref": "architecture:design-by-contract",
  "relations": [
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-preconditions",
          "json": "https://banes-lab.com/json/records/architecture/preconditions",
          "label": "Preconditions",
          "markdown": "https://banes-lab.com/records/architecture/preconditions.md",
          "ref": "architecture:preconditions"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-postconditions",
          "json": "https://banes-lab.com/json/records/architecture/postconditions",
          "label": "Postconditions",
          "markdown": "https://banes-lab.com/records/architecture/postconditions.md",
          "ref": "architecture:postconditions"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-invariant",
          "json": "https://banes-lab.com/json/records/architecture/invariant",
          "label": "Invariant",
          "markdown": "https://banes-lab.com/records/architecture/invariant.md",
          "ref": "architecture:invariant"
        }
      ],
      "relation": "requires"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-correctness",
          "json": "https://banes-lab.com/json/records/architecture/correctness",
          "label": "Correctness",
          "markdown": "https://banes-lab.com/records/architecture/correctness.md",
          "ref": "architecture:correctness"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-predictability",
          "json": "https://banes-lab.com/json/records/architecture/predictability",
          "label": "Predictability",
          "markdown": "https://banes-lab.com/records/architecture/predictability.md",
          "ref": "architecture:predictability"
        }
      ],
      "relation": "reinforces"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-contract-testing",
          "json": "https://banes-lab.com/json/records/lexicon/contract-testing",
          "label": "Contract Testing",
          "markdown": "https://banes-lab.com/records/lexicon/contract-testing.md",
          "ref": "lexicon:contract-testing"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-liskov-substitution",
          "json": "https://banes-lab.com/json/records/architecture/liskov-substitution",
          "label": "Liskov Substitution Principle (LSP)",
          "markdown": "https://banes-lab.com/records/architecture/liskov-substitution.md",
          "ref": "architecture:liskov-substitution"
        }
      ],
      "relation": "enables"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-implicit-behavior",
          "json": "https://banes-lab.com/json/records/lexicon/implicit-behavior",
          "label": "Implicit Behavior",
          "markdown": "https://banes-lab.com/records/lexicon/implicit-behavior.md",
          "ref": "lexicon:implicit-behavior"
        }
      ],
      "relation": "conflicts-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-development-speed",
          "json": "https://banes-lab.com/json/records/lexicon/development-speed",
          "label": "Development Speed",
          "markdown": "https://banes-lab.com/records/lexicon/development-speed.md",
          "ref": "lexicon:development-speed"
        }
      ],
      "relation": "tensions-with"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/schema#tension-design-by-contract-development-speed",
          "json": "https://banes-lab.com/json/records/tension/design-by-contract-development-speed",
          "label": "Design by Contract / Development Speed",
          "markdown": "https://banes-lab.com/records/tension/design-by-contract-development-speed.md",
          "ref": "tension:design-by-contract-development-speed"
        }
      ],
      "relation": "tensions"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/algorithms#algorithms-architectural-contract-algebra",
          "json": "https://banes-lab.com/json/records/algorithms/architectural-contract-algebra",
          "label": "Architectural Contract Algebra",
          "markdown": "https://banes-lab.com/records/algorithms/architectural-contract-algebra.md",
          "ref": "algorithms:architectural-contract-algebra"
        },
        {
          "href": "https://banes-lab.com/ontology/algorithms#algorithms-contract-based-verification-kernel",
          "json": "https://banes-lab.com/json/records/algorithms/contract-based-verification-kernel",
          "label": "Contract-Based Verification Kernel",
          "markdown": "https://banes-lab.com/records/algorithms/contract-based-verification-kernel.md",
          "ref": "algorithms:contract-based-verification-kernel"
        }
      ],
      "relation": "contracts"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-implicit-assumptions",
          "json": "https://banes-lab.com/json/records/lexicon/implicit-assumptions",
          "label": "Implicit Assumptions",
          "markdown": "https://banes-lab.com/records/lexicon/implicit-assumptions.md",
          "ref": "lexicon:implicit-assumptions"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-trusting-invalid-inputs",
          "json": "https://banes-lab.com/json/records/lexicon/trusting-invalid-inputs",
          "label": "Trusting Invalid Inputs",
          "markdown": "https://banes-lab.com/records/lexicon/trusting-invalid-inputs.md",
          "ref": "lexicon:trusting-invalid-inputs"
        }
      ],
      "relation": "violated-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-precondition-check",
          "json": "https://banes-lab.com/json/records/lexicon/precondition-check",
          "label": "Precondition Check",
          "markdown": "https://banes-lab.com/records/lexicon/precondition-check.md",
          "ref": "lexicon:precondition-check"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-postcondition-check",
          "json": "https://banes-lab.com/json/records/lexicon/postcondition-check",
          "label": "Postcondition Check",
          "markdown": "https://banes-lab.com/records/lexicon/postcondition-check.md",
          "ref": "lexicon:postcondition-check"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-invariant-check",
          "json": "https://banes-lab.com/json/records/lexicon/invariant-check",
          "label": "Invariant Check",
          "markdown": "https://banes-lab.com/records/lexicon/invariant-check.md",
          "ref": "lexicon:invariant-check"
        }
      ],
      "relation": "refactored-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology/schema#vocabulary-severity-recommended",
          "json": "https://banes-lab.com/json/records/vocabulary/severity-recommended",
          "label": "recommended",
          "markdown": "https://banes-lab.com/records/vocabulary/severity-recommended.md",
          "ref": "vocabulary:severity-recommended"
        }
      ],
      "relation": "severity"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/ontology#architecture-category-contracts-interfaces-compatibility",
          "json": "https://banes-lab.com/json/records/architecture-category/contracts-interfaces-compatibility",
          "label": "Contracts / Interfaces / Compatibility",
          "markdown": "https://banes-lab.com/records/architecture-category/contracts-interfaces-compatibility.md",
          "ref": "architecture-category:contracts-interfaces-compatibility"
        }
      ],
      "relation": "category"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/pag/templates#templates-families",
          "json": "https://banes-lab.com/json/pag/templates/templates-families",
          "label": "Template families",
          "markdown": "https://banes-lab.com/pag/templates/templates-families.md",
          "ref": "chapter:/pag/templates#templates-families"
        },
        {
          "href": "https://banes-lab.com/disciplined-methodology#a-seat-is-a-contract",
          "json": "https://banes-lab.com/json/disciplined-methodology/start/a-seat-is-a-contract",
          "label": "A seat is a contract",
          "markdown": "https://banes-lab.com/disciplined-methodology/start/a-seat-is-a-contract.md",
          "ref": "chapter:/disciplined-methodology#a-seat-is-a-contract"
        },
        {
          "href": "https://banes-lab.com/disciplined-methodology/collaborate#stating-an-invariant",
          "json": "https://banes-lab.com/json/disciplined-methodology/collaborate/stating-an-invariant",
          "label": "Stating an invariant",
          "markdown": "https://banes-lab.com/disciplined-methodology/collaborate/stating-an-invariant.md",
          "ref": "chapter:/disciplined-methodology/collaborate#stating-an-invariant"
        },
        {
          "href": "https://banes-lab.com/software-architecture/coverage#an-architecture-is-its-predicate-set",
          "json": "https://banes-lab.com/json/software-architecture/coverage/an-architecture-is-its-predicate-set",
          "label": "From intent to predicate",
          "markdown": "https://banes-lab.com/software-architecture/coverage/an-architecture-is-its-predicate-set.md",
          "ref": "chapter:/software-architecture/coverage#an-architecture-is-its-predicate-set"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-contracts-interfaces-compatibility",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-contracts-interfaces-compatibility",
          "label": "Contracts / Interfaces / Compatibility",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-contracts-interfaces-compatibility.md",
          "ref": "chapter:/ontology#architecture-category-contracts-interfaces-compatibility"
        },
        {
          "href": "https://banes-lab.com/ontology#architecture-category-correctness-determinism-verification",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-correctness-determinism-verification",
          "label": "Correctness / Determinism / Verification",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-correctness-determinism-verification.md",
          "ref": "chapter:/ontology#architecture-category-correctness-determinism-verification"
        },
        {
          "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#architecture-category-error-handling-resilience",
          "json": "https://banes-lab.com/json/ontology/principles/architecture-category-error-handling-resilience",
          "label": "Error Handling / Resilience",
          "markdown": "https://banes-lab.com/ontology/principles/architecture-category-error-handling-resilience.md",
          "ref": "chapter:/ontology#architecture-category-error-handling-resilience"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-contracts-interfaces-compatibility",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-contracts-interfaces-compatibility",
          "label": "Contracts / Interfaces / Compatibility",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-contracts-interfaces-compatibility.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-contracts-interfaces-compatibility"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-correctness-determinism-verification",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-correctness-determinism-verification",
          "label": "Correctness / Determinism / Verification",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-correctness-determinism-verification.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-correctness-determinism-verification"
        },
        {
          "href": "https://banes-lab.com/ontology/lexicon#lexicon-category-error-handling-resilience",
          "json": "https://banes-lab.com/json/ontology/lexicon/lexicon-category-error-handling-resilience",
          "label": "Error Handling / Resilience",
          "markdown": "https://banes-lab.com/ontology/lexicon/lexicon-category-error-handling-resilience.md",
          "ref": "chapter:/ontology/lexicon#lexicon-category-error-handling-resilience"
        },
        {
          "href": "https://banes-lab.com/ontology/algorithms#algorithms-domain-architecture",
          "json": "https://banes-lab.com/json/ontology/algorithms/algorithms-domain-architecture",
          "label": "Architecture",
          "markdown": "https://banes-lab.com/ontology/algorithms/algorithms-domain-architecture.md",
          "ref": "chapter:/ontology/algorithms#algorithms-domain-architecture"
        },
        {
          "href": "https://banes-lab.com/ontology/algorithms#algorithms-domain-context-verification",
          "json": "https://banes-lab.com/json/ontology/algorithms/algorithms-domain-context-verification",
          "label": "Context verification",
          "markdown": "https://banes-lab.com/ontology/algorithms/algorithms-domain-context-verification.md",
          "ref": "chapter:/ontology/algorithms#algorithms-domain-context-verification"
        },
        {
          "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 rule that every operation states the preconditions it needs, the postconditions it guarantees and the invariants it keeps.",
  "siblings": {
    "next": {
      "href": "https://banes-lab.com/ontology#architecture-explicit-contracts",
      "json": "https://banes-lab.com/json/records/architecture/explicit-contracts",
      "label": "Explicit Contracts",
      "markdown": "https://banes-lab.com/records/architecture/explicit-contracts.md",
      "ref": "architecture:explicit-contracts"
    },
    "previous": {
      "href": "https://banes-lab.com/ontology#architecture-pacelc-theorem",
      "json": "https://banes-lab.com/json/records/architecture/pacelc-theorem",
      "label": "PACELC Theorem",
      "markdown": "https://banes-lab.com/records/architecture/pacelc-theorem.md",
      "ref": "architecture:pacelc-theorem"
    }
  },
  "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": [
    "DbC"
  ],
  "exemplar": {
    "after": "function divideFoo(total: number, count: number): number {\n  if (!Number.isFinite(total)) throw new Error(\"pre: total must be finite\");\n  if (!Number.isInteger(count) || count <= 0) throw new Error(\"pre: count must be positive\");\n  const result = total / count;\n  if (!Number.isFinite(result)) throw new Error(\"post: result must be finite\");\n  return result;\n}",
    "before": "function divideFoo(total: number, count: number) {\n  return total / count;\n}",
    "lang": "ts",
    "medium": "code"
  },
  "formedBy": null,
  "scope": [
    "API",
    "function",
    "class",
    "service"
  ],
  "severity": "recommended"
}
