Lazy Class
Refactoring & Technical Debt

Meaning

A class that does too little, often delegating all its work to other classes or containing little behavior, indicating a potential design smell.

Primary Function

Signals a design smell indicating a class with insufficient responsibility, suggesting removal or merging.

Communicative Purpose

Alerts developers to a potential design flaw that may indicate unnecessary complexity or missed abstraction.

Pattern

Detect a class with minimal behavior → consider merging it into a more cohesive class or removing it.

Função primária

Signals a design smell indicating a class with insufficient responsibility, suggesting removal or merging.

Propósito comunicativo

Alerts developers to a potential design flaw that may indicate unnecessary complexity or missed abstraction.

Situações de gatilho

When a class has few methods, little state, or merely delegates behavior to other classes.

Contextos

During code reviews, refactoring sessions, or when reviewing object-oriented design for smells.

Padrão

Detect a class with minimal behavior → consider merging it into a more cohesive class or removing it.

Colocados típicos

  • Extract Class
  • Collapse Hierarchy
  • Refactor
  • Code Smell detection tools
  • Design Review

Substituições comuns

  • Replace with a Data Class (holds data only) – may still be too thin
  • Use a Utility Class (static methods) – shifts responsibility
  • Merge into an existing Service class – consolidates behavior

Erros comuns

Treating a lazy class as a separate entity → unnecessary indirection; Assuming delegation adds value → increased coupling; Removing the class without consolidating its behavior → loss of abstraction

Similar / contraste

God Class (excessive responsibilities) – opposite extreme; Data Class (holds data only) – similar thinness but intentional; Utility Class (static helpers) – not an object instance

Interferências

Coming from Java: may create a lazy class to group static methods → in Python prefer a module; Coming from C++: might use inheritance to delegate behavior → can hide the laziness and increase complexity

Família do chunk

  • God Class
  • Data Class
  • Feature Envy
  • Data Clumps
  • Lazy Class

Nuance

Do not introduce a lazy class when the class already has a clear, single responsibility; It has no measurable performance impact but adds indirection that can affect readability; Only consider it acceptable when it acts as a façade for a stable external API.

Efeito pragmático

Eliminating lazy classes reduces codebase size, improves maintainability, and prevents unnecessary indirection.

Dica de memória

A lazy class is like a middleman who never does any work themselves, just passes messages to others.

Nota

Lazy Class is part of the broader "Large Class" smell family and often co-occurs with Feature Envy.

Upgrade path

Learn refactoring techniques such as Extract Class or Collapse Hierarchy to eliminate lazy classes.

Frequência: HighFormulaicidade: FixedTipo de construção: conceptPrioridade de aquisição: Recognition firstPrioridade de output: BothTag de espaçamento: Medium-term

Log in to save chunks.