What are SOLID Principles?
Principle | Full name | Description |
---|---|---|
SRP | The Single Responsibility Principle | A class should have one, and only one, reason to change. |
OCP | The Open Closed Principle | You should be able to extend a classes behavior, without modifying it. |
LSP | The Liskov Substitution Principle | Derived classes must be substitutable for their base classes. |
ISP | The Interface Segregation Principle | Make fine grained interfaces that are client specific. |
DIP | The Dependency Inversion Principle | Depend 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