cln.co/
SRP
SRPSingle Responsibility Principle

"A class should have only one reason to change." - Robert C. Martin

Key Takeaways
  • One class should have one job, not many.
  • Keeping jobs separate makes code easier to fix and change.
  • Simple, focused classes are better for reuse.

Description

A function or class should have one, and only one, reason to change, meaning it should have a single responsibility or function within a software system.

"Gather together the things that change for the same reasons. Separate those things that change for different reasons." - Robert C. Martin

Begin with a list of difficult design decisions (things that are likely to change) - each module is then designed to hide such a decision from the others.

A variable should mean one thing, and one thing only. It should not mean one thing in one circumstance, and carry a different value from a different domain some other time.

You might also like:
ADP
APO
BSR
CCP
CoI
CQS
CRP
DIP
DRY
EUHM
EWV
FF
FTSE
GRASP
HC
HLYW
IH
IoC
IOSP
ISP
KISS
LC
LoD
LOLA
LSP
OCP
POLP
POLS
PoMO
REP
RoT
RTFM
SAP
SDB
SDP
SLA
SoC
SOLDIER
SOLID
SPOT
SRP
TdA
WET
YAGNI
ZOI