Canonical: https://weaveos.com/glossary/law-of-demeter

[Home](https://weaveos.com/)/[Glossary](https://weaveos.com/glossary)/[Code quality and technical debt](https://weaveos.com/glossary/category/code-quality-technical-debt)/Law of Demeter

[Code quality and technical debt](https://weaveos.com/glossary/category/code-quality-technical-debt)

# Law of Demeter

Also known as Law of Demeter, Law of Demeter in software engineering

By WeavePublished September 10, 20261 min read

## Definition

A guideline that limits how many unrelated object relationships a method navigates directly.

On this page

1. [Definition](https://weaveos.com/glossary/law-of-demeter#definition)
2. [What it means](https://weaveos.com/glossary/law-of-demeter#article-what-it-means)
3. [Example](https://weaveos.com/glossary/law-of-demeter#article-example)
4. [Limitations](https://weaveos.com/glossary/law-of-demeter#article-limitations)
5. [How to use the signal](https://weaveos.com/glossary/law-of-demeter#article-how-to-use-the-signal)
6. [How this relates to Weave](https://weaveos.com/glossary/law-of-demeter#weave)
7. [Sources](https://weaveos.com/glossary/law-of-demeter#sources)
8. [Related terms](https://weaveos.com/glossary/law-of-demeter#related)

## What it means

The Law of Demeter encourages a method to talk to close collaborators rather than reaching through chains of objects. Expressions such as `order.customer.account.address` can expose knowledge of internal structure and make changes ripple across callers. The guideline favors messages that match responsibility boundaries.

## Example

A notification service asks an order for a delivery address instead of navigating through customer, account, and profile objects. The order owns the path to its address and can change its internal representation.

## Limitations

Strictly banning every chained call can produce needless forwarding methods and hide simple data access. Fluent APIs and immutable transformations may use chains intentionally. Consider coupling and change impact, not syntax alone.

## How to use the signal

Judge the stability of the relationship behind a call chain instead of banning fluent or deliberately compositional APIs.

Weave can help identify whether navigation-heavy changes produce review iteration or rework. Static rules can find patterns, but engineers must decide whether the relationships are genuinely unstable.

## How this relates to Weave

Weave can help identify whether navigation-heavy changes produce review iteration or rework. Static rules can find patterns, but engineers must decide whether the relationships are genuinely unstable.

[Explore Engineering intelligence](https://weaveos.com/products/engineering-intelligence)

## Sources and further reading

1. [SonarSource code metrics and analysis documentation](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/code-metrics/metrics-definition/)

## Related terms

### [Engineering analytics](https://weaveos.com/glossary/engineering-analytics)

[What engineering analytics measures, how to interpret delivery and code data, and how Weave connects engineering activity to useful outcomes.](https://weaveos.com/glossary/engineering-analytics)

### [Developer productivity](https://weaveos.com/glossary/developer-productivity)

[Understand developer productivity, why activity counts are incomplete, and how to evaluate delivery, quality, and AI-assisted engineering work.](https://weaveos.com/glossary/developer-productivity)
