{
  "id": 18874336,
  "title": "S — Single Responsibility Principle — SOLID Principles with Examples",
  "url": "https://urgent.news/2026/11/08/s-single-responsibility-principle-solid-principles-with-examples",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-08T06:09:54.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/divakarupadhyay/s-single-responsibility-principle-solid-principles-with-examples-1e88"
  },
  "original_language": "en",
  "account": "The Single Responsibility Principle (SRP) asserts that a class should possess only one reason to change. This implies that each class should have one cohesive job, with no more than one compelling motive for alteration. Changing the class responsible for formatting invoices, saving them, and emailing them simultaneously violates SRP. Altering the invoice formatting method, the data storage mechanism, or the email delivery service would all necessitate modifications to the class.",
  "summary": "Lesson 1 of 8 in the free SOLID Principles with Examples course on DevLadder. \"A class should have one, and only one, reason to change.\" — Robert C. Martin \"Reason to change\" = one actor or stakeholder. A class that formats invoices and saves them and emails them changes when finance, DBAs or the email provider change. // ❌ Violates SRP — three reasons to change public class InvoiceService {…",
  "key_points": [
    "Single Responsibility Principle (SRP) states a class should have one reason to change",
    "Changing invoice formatting, data storage, or email delivery requires class modifications"
  ],
  "editors_take": "Isolating specific tasks into dedicated classes prevents a single change in functionality from forcing unnecessary modifications across multiple unrelated software components.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}