Lazy Element — Code Smells Catalog Skip to content

Lazy Element

Also known as: Lazy Class

Dispensables Unnecessary Complexity AntipatternCode SmellDesign Smell Between Class

The meeting that could have been an email — except it's a class. One field, one method that just delegates to another, an abstraction that costs more in complexity than it ever returns in clarity.

1 min read 2 sources

Overview

A Lazy Element is an element that does not do enough. If a method, variable, or class does not do enough to pay for itself (for increased complexity of the project), it should be combined into another entity.

Causation

This smell can happen due to the aggressive refactorization process in which the functionality of a class was truncated. It can also occur due to the unnecessary pre-planning - Speculative Generality - developer made it in anticipation of a future need that never eventuates.

Problems

🧩
Increased Complexity

Projects complexity increases with the number of entities.

Example

1class Strength:
2    value: int
3
4class Person:
5    health: int
6    intelligence: int
7    strength: Strength
PYTHON

Refactoring

  • Inline Class
  • Inline Function
  • Collapse Hierarchy

Sources

Browse All 56 Smells