What are SOLID Principles?

PrincipleFull nameDescription
SRPThe Single Responsibility PrincipleA class should have one, and only one, reason to change.
OCPThe Open Closed PrincipleYou should be able to extend a classes behavior, without modifying it.
LSPThe Liskov Substitution PrincipleDerived classes must be substitutable for their base classes.
ISPThe Interface Segregation PrincipleMake fine grained interfaces that are client specific.
DIPThe Dependency Inversion PrincipleDepend on abstractions, not on concretions.
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod

๋‹จ์ผ ์ฑ…์ž„ ์›์น™ SRP (Single Responsibility Principle)

A class should have one, and only one, reason to change.

A module should be responsible to one, and only one, actor.

๋ชฉํ‘œ

  • ํด๋ž˜์Šค๊ฐ€ ๋ณ€๊ฒฝ๋์„ ๋•Œ ์˜ํ–ฅ์„ ๋ฐ›๋Š” ์•กํ„ฐ๊ฐ€ ํ•˜๋‚˜์—ฌ์•ผ ํ•œ๋‹ค.
  • ํด๋ž˜์Šค๋ฅผ ๋ณ€๊ฒฝํ•  ์ด์œ ๋Š” ์œ ์ผํ•œ ์•กํ„ฐ์˜ ์š”๊ตฌ์‚ฌํ•ญ์ด ๋ณ€๊ฒฝ๋  ๋•Œ๋กœ ์ œํ•œ๋˜์–ด์•ผ ํ•œ๋‹ค.

๊ฐœ๋ฐฉ ํ์‡„ ์›์น™ OCP (Open-Closed Principle)

You should be able to extend a classes behavior, without modifying it.

๋ฆฌ์Šค์ฝ”ํ”„ ์น˜ํ™˜ ์›์น™ LSP (Liskov Substitution Principle)

Derived classes must be substitutable for their base classes.

์ธํ„ฐํŽ˜์ด์Šค ๋ถ„๋ฆฌ ์›์น™ ISP (Interface Segregation Principle)

Make fine grained interfaces that are client specific