Code quality and technical debt

Speculative generality

Also known as Speculative generality, Speculative generality in software engineering

By WeavePublished 1 min read

Definition

A code smell in which abstractions or extension points exist for hypothetical future needs.

What it means

Speculative generality is unnecessary flexibility introduced before a real variation or consumer exists. It can increase indirection, documentation burden, and mental overhead. Removing it may make current behavior clearer, but only after checking configuration, plugins, and planned compatibility commitments.

Example

A repository contains a strategy interface with one implementation and no planned alternate behavior. The team records the decision and simplifies the path until a second real use case appears.

Limitations

An apparently unused abstraction may be required by generated code or an external integration. Future variation can also be expensive to add later. Review evidence and constraints before deleting extension points.

How to use the signal

A real second use case is stronger evidence for generalization than a hypothetical feature request or an unused configuration switch.

Confirm external contracts and extension commitments before deleting an abstraction that appears unused.

Weave can connect simplification work to review duration and code churn. Use repository search and ownership checks to validate the scope, then inspect workflow evidence.

How this relates to Weave

Weave can connect simplification work to review duration and code churn. Use repository search and ownership checks to validate the scope, then inspect workflow evidence.

Explore Engineering intelligence

Sources and further reading

  1. SonarSource code metrics and analysis documentation