wonslee / object-study

📔오브젝트 예제 코드를 따라 공부, 토론하는 스터디 그룹
0 stars 1 forks source link

OCP vs DIP #41

Open wonslee opened 8 months ago

wonslee commented 8 months ago

9장을 읽으면서 OCP, DIP가 정말 공통점이 많다는 생각이 들었습니다.
둘 모두 유연한 설계를 위해서, 낮은 결합도를 위해서 지켜져야 하는 원칙이라는 점에서 같고
그 수단으로 추상화를 사용한다는 점에서 같았어요.

둘의 차이가 뭐라고 생각하시나요?

wonslee commented 8 months ago

구글링해보니까 OCP가 DIP보다 넓은 개념이고, DIP는 OCP와 LSP를 지키다보면 자연스럽게 지켜지는 원칙이라고 하네요.

https://stackoverflow.com/questions/18428027/what-is-difference-between-the-open-closed-principle-and-the-dependency-inversio

Uncle Bob Martin, who popularized the Open-Closed Principle (OCP) and Dependency Inversion Principles (DIP) as two of the SOLID principles, states himself that DIP arises from an application of OCP and the Liskov Substitution Principle: