[{"data":1,"prerenderedAt":225},["ShallowReactive",2],{"term-s\u002Fsingle-responsibility":3,"related-s\u002Fsingle-responsibility":211},{"id":4,"title":5,"acronym":6,"body":7,"category":193,"description":194,"difficulty":195,"extension":196,"letter":197,"meta":198,"navigation":109,"path":199,"related":200,"seo":205,"sitemap":206,"stem":209,"subcategory":6,"__hash__":210},"terms\u002Fterms\u002Fs\u002Fsingle-responsibility.md","Single Responsibility",null,{"type":8,"value":9,"toc":187},"minimark",[10,15,19,23,26,30,176,180,183],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"Single Responsibility means every class or function should do ONE thing and do it well. A class called UserEmailPasswordDatabaseLogger is screaming 'I do too much!' Split it up. A chef shouldn't also fix the plumbing.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"The Single Responsibility Principle (SRP) states that a class or module should have only one reason to change — meaning it should encapsulate only one aspect of functionality. Violating SRP creates fragile, tightly coupled code that breaks when unrelated requirements change.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Bad: two reasons to change\nclass User {\n  save() { \u002F* DB logic *\u002F }\n  sendWelcomeEmail() { \u002F* Email logic *\u002F }\n}\n\n\u002F\u002F Good: one responsibility each\nclass UserRepository { save(user) { \u002F* DB logic *\u002F } }\nclass UserEmailService { sendWelcome(user) { \u002F* Email logic *\u002F } }\n","javascript","",[38,39,40,49,64,83,98,104,111,117,149],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F Bad: two reasons to change\n",[41,50,52,56,60],{"class":43,"line":51},2,[41,53,55],{"class":54},"spNyl","class",[41,57,59],{"class":58},"sBMFI"," User",[41,61,63],{"class":62},"sMK4o"," {\n",[41,65,67,71,74,77,80],{"class":43,"line":66},3,[41,68,70],{"class":69},"swJcz","  save",[41,72,73],{"class":62},"()",[41,75,76],{"class":62}," {",[41,78,79],{"class":47}," \u002F* DB logic *\u002F",[41,81,82],{"class":62}," }\n",[41,84,86,89,91,93,96],{"class":43,"line":85},4,[41,87,88],{"class":69},"  sendWelcomeEmail",[41,90,73],{"class":62},[41,92,76],{"class":62},[41,94,95],{"class":47}," \u002F* Email logic *\u002F",[41,97,82],{"class":62},[41,99,101],{"class":43,"line":100},5,[41,102,103],{"class":62},"}\n",[41,105,107],{"class":43,"line":106},6,[41,108,110],{"emptyLinePlaceholder":109},true,"\n",[41,112,114],{"class":43,"line":113},7,[41,115,116],{"class":47},"\u002F\u002F Good: one responsibility each\n",[41,118,120,122,125,127,130,133,137,140,142,144,147],{"class":43,"line":119},8,[41,121,55],{"class":54},[41,123,124],{"class":58}," UserRepository",[41,126,76],{"class":62},[41,128,129],{"class":69}," save",[41,131,132],{"class":62},"(",[41,134,136],{"class":135},"sHdIc","user",[41,138,139],{"class":62},")",[41,141,76],{"class":62},[41,143,79],{"class":47},[41,145,146],{"class":62}," }",[41,148,82],{"class":62},[41,150,152,154,157,159,162,164,166,168,170,172,174],{"class":43,"line":151},9,[41,153,55],{"class":54},[41,155,156],{"class":58}," UserEmailService",[41,158,76],{"class":62},[41,160,161],{"class":69}," sendWelcome",[41,163,132],{"class":62},[41,165,136],{"class":135},[41,167,139],{"class":62},[41,169,76],{"class":62},[41,171,95],{"class":47},[41,173,146],{"class":62},[41,175,82],{"class":62},[11,177,179],{"id":178},"when-youll-hear-this","When You'll Hear This",[16,181,182],{},"\"This class violates Single Responsibility — split the email logic out.\" \u002F \"SRP keeps classes small and focused.\"",[184,185,186],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":188},[189,190,191,192],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":178,"depth":51,"text":179},"architecture","Single Responsibility means every class or function should do ONE thing and do it well.","beginner","md","s",{},"\u002Fterms\u002Fs\u002Fsingle-responsibility",[201,202,203,204],"SOLID","Separation of Concerns","Cohesion","Refactoring",{"title":5,"description":194},{"changefreq":207,"priority":208},"weekly",0.7,"terms\u002Fs\u002Fsingle-responsibility","E5rqtQvk6riNi-iGi-dFBwZF7LVow_WzfnAvlqQrZwY",[212,216,219,222],{"title":203,"path":213,"acronym":6,"category":193,"difficulty":214,"description":215},"\u002Fterms\u002Fc\u002Fcohesion","intermediate","Cohesion is how well the things inside a module belong together. High cohesion means all the stuff in a class is related — like a toolbox full of tools.",{"title":204,"path":217,"acronym":6,"category":193,"difficulty":195,"description":218},"\u002Fterms\u002Fr\u002Frefactoring","Refactoring is improving the internal structure of code WITHOUT changing what it does from the outside.",{"title":202,"path":220,"acronym":6,"category":193,"difficulty":195,"description":221},"\u002Fterms\u002Fs\u002Fseparation-of-concerns","Separation of Concerns means different parts of your code should handle different concerns and not step on each other's toes.",{"title":201,"path":223,"acronym":201,"category":193,"difficulty":214,"description":224},"\u002Fterms\u002Fs\u002Fsolid","SOLID is five rules for writing code that doesn't turn into a nightmare over time. Each letter stands for a different rule.",1776518313419]