Saltar al contenido
AKOS
Todos los packs
StableArquitecturasolid

SOLID Principles

Operationalizes the five SOLID class/module design principles — Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion — as concrete checks, with explicit guidance on when applying them adds value vs. adds ceremony.

solidoopcouplingcohesiondependency-inversionclass-design

Principios

  • · Aplica los principios documentados en el pack solid.

Patrones

  • · The "and" test (SRP): describe the class in one sentence; if it needs "and" ("handles order validation *and* sends emails"), split it.
  • · The edit-existing test (OCP): adding a new case requires editing an existing tested switch/if chain → candidate for polymorphism, but only after the second or third case appears, not preemptively for the first.
  • · The "throws NotSupported" smell (LSP): a subclass overriding a method to throw or no-op signals the hierarchy models the wrong relationship.
  • · The unused-methods test (ISP): if a class implementing an interface stubs out half its methods, the interface is fat — split by actual client need.
  • · The "new" grep (DIP): business logic instantiating concrete infra classes directly (new SqlClient() inside a use case) is an inversion violation; check whether an interface already exists nearby before adding one.

Riesgos

  • · Ver anti-patrones específicos del dominio en el pack.

Checklist

  • [ ] No class edited by unrelated stakeholders for unrelated reasons without cause to split. (SD1)
  • [ ] Adding a variant to existing multi-case behavior doesn't require editing tested existing cases. (SD2)
  • [ ] No subclass overrides throw/no-op to narrow a contract. (SD3)
  • [ ] Business logic depends on interfaces, not concrete infra classes, wherever a second implementation exists or tests need isolation. (SD5)
  • [ ] Interfaces sized to actual client usage — no stub implementations. (SD4)
  • [ ] No interface/strategy pattern introduced for a single stable case. (SD6)

Fuentes

En la bibliografía AKOS